Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get cluster-health from etcd api

Tags:

etcd

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?

like image 308
Derek Brown Avatar asked Oct 30 '25 05:10

Derek Brown


2 Answers

etcdctl cluster-health is deprecated in V3, you can use the command below instead:

etcdctl --cluster=true endpoint health

like image 183
Mehran Mehravari Avatar answered Nov 01 '25 11:11

Mehran Mehravari


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.

like image 23
Derek Brown Avatar answered Nov 01 '25 12:11

Derek Brown