Cluster Health provides a lot of information about the cluster, such as the number of shards that are allocated ("active") as well as how many are unassigned and relocating. In addition, it provides the current number of nodes and data nodes in the cluster, which can allow you to poll for missing nodes (e.g., if you expect it to be 15
, but it only shows 14
, then you are missing a node).
For someone that knows about Elasticsearch, "assigned" and "unassigned" shards can help them to track down issues.
The most common field checked from Cluster Health is the status
, which can be in one of three states:
The colors each mean one -- and only one -- very simple thing:
initializing_shards
).initializing_shards
).relocating_shards
.Example uses basic HTTP syntax. Any <#>
in the example should be removed when copying it.
You can use the _cat
APIs to get a human readable, tabular output for various reasons.
GET /_cat/health?v <1>
?v
is optional, but it implies that you want "verbose" output._cat/health
has existed since Elasticsearch 1.x, but here is an example of its output from Elasticsearch 5.x:
With verbose output:
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1469302011 15:26:51 elasticsearch yellow 1 1 45 45 0 0 44 0 - 50.6%
Example uses basic HTTP syntax. Any <#>
in the example should be removed when copying it.
You can use the _cat
APIs to get a human readable, tabular output for various reasons.
GET /_cat/health <1>
_cat/health
has existed since Elasticsearch 1.x, but here is an example of its output from Elasticsearch 5.x:
Without verbose output:
1469302245 15:30:45 elasticsearch yellow 1 1 45 45 0 0 44 0 - 50.6%
Example uses basic HTTP syntax. Any <#>
in the example should be removed when copying it.
Like most _cat
APIs in Elasticsearch, the API selectively responds with a default set of fields. However, other fields exist from the API if you want them:
GET /_cat/health?help <1>
?help
causes the API to return the fields (and short names) as well as a brief description._cat/health
has existed since Elasticsearch 1.x, but here is an example of its output from Elasticsearch 5.x:
Fields available as-of this example's creation date:
epoch | t,time | seconds since 1970-01-01 00:00:00
timestamp | ts,hms,hhmmss | time in HH:MM:SS
cluster | cl | cluster name
status | st | health status
node.total | nt,nodeTotal | total number of nodes
node.data | nd,nodeData | number of nodes that can store data
shards | t,sh,shards.total,shardsTotal | total number of shards
pri | p,shards.primary,shardsPrimary | number of primary shards
relo | r,shards.relocating,shardsRelocating | number of relocating nodes
init | i,shards.initializing,shardsInitializing | number of initializing nodes
unassign | u,shards.unassigned,shardsUnassigned | number of unassigned shards
pending_tasks | pt,pendingTasks | number of pending tasks
max_task_wait_time | mtwt,maxTaskWaitTime | wait time of longest task pending
active_shards_percent | asp,activeShardsPercent | active number of shards in percent
You can then use this to print only those fields:
GET /_cat/health?h=timestamp,cl,status&v <1>
h=...
defines the list of fields that you want returned.v
(verbose) defines that you want it to print the headers.The output from an instance of Elasticsearch 5.x:
timestamp cl status
15:38:00 elasticsearch yellow
Example uses basic HTTP syntax. Any <#>
in the example should be removed when copying it.
The _cat
APIs are often convenient for humans to get at-a-glance details about the cluster. But you frequently want consistently parseable output to use with software. In general, the JSON APIs are meant for this purpose.
GET /_cluster/health
_cluster/health
has existed since Elasticsearch 1.x, but here is an example of its output from Elasticsearch 5.x:
{
"cluster_name": "elasticsearch",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 45,
"active_shards": 45,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 44,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks": 0,
"number_of_in_flight_fetch": 0,
"task_max_waiting_in_queue_millis": 0,
"active_shards_percent_as_number": 50.56179775280899
}