CAT Health API
Introduced 1.0
The CAT health operation lists the status of the cluster, how long the cluster has been up, the number of nodes, and other useful information that helps you analyze the health of your cluster. It returns the same information as the Cluster Health API in a compact, single-line format.
Each response line starts with two timestamps: epoch, the time in seconds since the Unix epoch, and timestamp, the time of day in HH:MM:SS format. The epoch value includes the date, so use it to sort or compare results collected over several days. To omit both timestamps, set ts to false.
Because each call returns one line, the CAT Health API is useful for monitoring a cluster over time, for example, while the cluster recovers after a restart. The following command checks the cluster health every 60 seconds:
while true; do curl -s "localhost:9200/_cat/health?h=epoch,timestamp,status,init,unassign"; sleep 60; done
As the recovery progresses, the cluster status changes from red to yellow to green, and the number of unassigned shards (unassign) decreases. If unassign stays the same across several checks, use the Cluster Allocation Explain API to find out why shards are not being assigned.
Endpoints
GET /_cat/health
Query parameters
The following table lists the available query parameters. All query parameters are optional.
| Parameter | Data type | Description | Default |
|---|---|---|---|
format | String | A short version of the Accept header, such as json or yaml. | N/A |
h | List | A comma-separated list of column names to display. | N/A |
help | Boolean | Returns help information. | false |
s | List | A comma-separated list of column names or column aliases to sort by. | N/A |
time | String | The unit used to display time values. Valid values are: nanos, micros, ms, s, m, h, and d. | N/A |
ts | Boolean | When true, returns HH:MM:SS and Unix epoch timestamps. | true |
v | Boolean | Enables verbose mode, which displays column headers. | false |
Example request
The following example request give cluster health information for the past 5 days:
GET /_cat/health?v&time=5dresponse = client.cat.health(
params = { "v": "true", "time": "5d" }
)Example response
GET _cat/health?v&time=5d
epoch | timestamp | cluster | status | node.total | node.data | shards | pri | relo | init | unassign | pending_tasks | max_task_wait_time | active_shards_percent
1624248112 | 04:01:52 | odfe-cluster | green | 2 | 2 | 16 | 8 | 0 | 0 | 0 | 0 | - | 100.0%
Required permissions
If you use the Security plugin, make sure you have the appropriate permissions: cluster:monitor/health.