etcd

Get cluster-health from etcd api


From the command line, I can run the following command to get the cluster health of an etcd cluster, like this:

etcdctl cluster-health
member ac92bd2949b92e96 is healthy: got healthy result from https://172.31.26.170:2379
member bebdb18e18d35331 is healthy: got healthy result from https://172.31.21.117:2379
member c1c4d5cb0d474453 is healthy: got healthy result from https://172.31.18.126:2379

However, I can't seem to find the same functionality documented in the API specification. How do I programmatically determine if a cluster is healthy from the REST API?


Solution

  • EDIT (4/17/24): This answer is applicable for etcd API v2. These endpoints are no longer supported in etcd API v3.

    Got an answer from Github, thought I would pass it along-

    There is no single API call which returns the cluster health for all nodes in the cluster. In order to do this, you need to:

    1. Make a call to the members API to get a list of all of the members in the cluster.

    2. Make a call to the /health endpoint to get the health of each endpoint.