How to monitor degraded state of service

I’m looking for a temporary solution for a health-monitoring notifications services until Ranhcer release alarms feature. I started working on a service which poll Rancher API, but encounter that degraded state is only present in UI, in API it is still active. Is any possibility to figure out that service is in degraded state using API?

Don’t tell me please to parse UI… lol

Shall i poll containers for each each service and if there is at least one in healthState: 'initializing' mark service as unhealthy?

Degraded is not a “real” state, but a combination in the UI of state: active and healthState not healthy per-container, then aggregated up to the service and stack. So you probably want something similar.

initializing is the initial healthState when started until the checks are passing. If they subsequently fail it would go to unhealthy.