Health check recovery notice?

Let’s say that I have a service that temporarily fails a health check in Consul. e.g. due to failing connection to DB or overload.

Other services will be able to see this through health check status on this specific service.

But, is there anyway for the service itself, to get informed that the rest of the system saw it as unavailable for some time?
Can I make a service self-aware that it was unavailable and is now available, from consuls perspective that is?, not checking internal things.

Hi @rogeralsing,

Welcome to our community! :wave:

You can write a script which sets up a blocking query on the /v1//health/checks/:service endpoint which filters on that specific service instance ID (e.g., /v1/health/checks/db\?filter="ServiceID==db1"&index=<X-Consul-Index>), and then execute some action when the health check changes state.

Does that sound like a viable solution?

2 Likes