2013-11-14 20:14:39 -05:00
|
|
|
[[cat-health]]
|
2019-07-19 14:35:36 -04:00
|
|
|
=== cat health
|
2013-11-14 20:14:39 -05:00
|
|
|
|
|
|
|
`health` is a terse, one-line representation of the same information
|
2016-10-07 16:28:49 -04:00
|
|
|
from `/_cluster/health`.
|
2013-11-14 20:14:39 -05:00
|
|
|
|
2016-10-07 16:28:49 -04:00
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
GET /_cat/health?v
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[s/^/PUT twitter\n{"settings":{"number_of_replicas": 0}}\n/]
|
|
|
|
|
2016-10-25 10:56:30 -04:00
|
|
|
[source,txt]
|
2016-10-07 16:28:49 -04:00
|
|
|
--------------------------------------------------
|
2016-10-11 17:42:43 -04:00
|
|
|
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
|
2018-05-14 12:22:35 -04:00
|
|
|
1475871424 16:17:04 elasticsearch green 1 1 1 1 0 0 0 0 - 100.0%
|
2016-10-07 16:28:49 -04:00
|
|
|
--------------------------------------------------
|
2017-04-28 09:56:19 -04:00
|
|
|
// TESTRESPONSE[s/1475871424 16:17:04/\\d+ \\d+:\\d+:\\d+/]
|
2019-06-10 09:33:32 -04:00
|
|
|
// TESTRESPONSE[s/elasticsearch/[^ ]+/ s/0 -/\\d+ (-|\\d+(\\.\\d+)?[ms]+)/ non_json]
|
2016-10-07 16:28:49 -04:00
|
|
|
|
|
|
|
It has one option `ts` to disable the timestamping:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2017-01-19 01:59:18 -05:00
|
|
|
GET /_cat/health?v&ts=false
|
2016-10-07 16:28:49 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[s/^/PUT twitter\n{"settings":{"number_of_replicas": 0}}\n/]
|
|
|
|
|
|
|
|
which looks like:
|
|
|
|
|
2016-10-25 10:56:30 -04:00
|
|
|
[source,txt]
|
2013-11-14 20:14:39 -05:00
|
|
|
--------------------------------------------------
|
2016-10-11 17:42:43 -04:00
|
|
|
cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
|
2018-05-14 12:22:35 -04:00
|
|
|
elasticsearch green 1 1 1 1 0 0 0 0 - 100.0%
|
2013-11-14 20:14:39 -05:00
|
|
|
--------------------------------------------------
|
2019-06-10 09:33:32 -04:00
|
|
|
// TESTRESPONSE[s/elasticsearch/[^ ]+/ s/0 -/\\d+ (-|\\d+(\\.\\d+)?[ms]+)/ non_json]
|
2013-11-14 20:14:39 -05:00
|
|
|
|
|
|
|
A common use of this command is to verify the health is consistent
|
|
|
|
across nodes:
|
|
|
|
|
2015-07-14 12:14:09 -04:00
|
|
|
[source,sh]
|
2013-11-14 20:14:39 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
% pssh -i -h list.of.cluster.hosts curl -s localhost:9200/_cat/health
|
|
|
|
[1] 20:20:52 [SUCCESS] es3.vm
|
2015-02-25 07:25:52 -05:00
|
|
|
1384309218 18:20:18 foo green 3 3 3 3 0 0 0 0
|
2013-11-14 20:14:39 -05:00
|
|
|
[2] 20:20:52 [SUCCESS] es1.vm
|
2015-02-25 07:25:52 -05:00
|
|
|
1384309218 18:20:18 foo green 3 3 3 3 0 0 0 0
|
2013-11-14 20:14:39 -05:00
|
|
|
[3] 20:20:52 [SUCCESS] es2.vm
|
2015-02-25 07:25:52 -05:00
|
|
|
1384309218 18:20:18 foo green 3 3 3 3 0 0 0 0
|
2013-11-14 20:14:39 -05:00
|
|
|
--------------------------------------------------
|
2016-10-07 16:28:49 -04:00
|
|
|
// NOTCONSOLE
|
2013-11-14 20:14:39 -05:00
|
|
|
|
|
|
|
A less obvious use is to track recovery of a large cluster over
|
|
|
|
time. With enough shards, starting a cluster, or even recovering after
|
|
|
|
losing a node, can take time (depending on your network & disk). A way
|
|
|
|
to track its progress is by using this command in a delayed loop:
|
|
|
|
|
2015-07-14 12:14:09 -04:00
|
|
|
[source,sh]
|
2013-11-14 20:14:39 -05:00
|
|
|
--------------------------------------------------
|
2015-11-04 12:00:41 -05:00
|
|
|
% while true; do curl localhost:9200/_cat/health; sleep 120; done
|
2015-02-25 07:25:52 -05:00
|
|
|
1384309446 18:24:06 foo red 3 3 20 20 0 0 1812 0
|
|
|
|
1384309566 18:26:06 foo yellow 3 3 950 916 0 12 870 0
|
|
|
|
1384309686 18:28:06 foo yellow 3 3 1328 916 0 12 492 0
|
2013-11-14 20:14:39 -05:00
|
|
|
1384309806 18:30:06 foo green 3 3 1832 916 4 0 0
|
|
|
|
^C
|
|
|
|
--------------------------------------------------
|
2016-10-07 16:28:49 -04:00
|
|
|
// NOTCONSOLE
|
2013-11-14 20:14:39 -05:00
|
|
|
|
|
|
|
In this scenario, we can tell that recovery took roughly four minutes.
|
|
|
|
If this were going on for hours, we would be able to watch the
|
|
|
|
`UNASSIGNED` shards drop precipitously. If that number remained
|
|
|
|
static, we would have an idea that there is a problem.
|
|
|
|
|
|
|
|
[float]
|
|
|
|
[[timestamp]]
|
2019-07-19 14:35:36 -04:00
|
|
|
==== Why the timestamp?
|
2013-11-14 20:14:39 -05:00
|
|
|
|
|
|
|
You typically are using the `health` command when a cluster is
|
|
|
|
malfunctioning. During this period, it's extremely important to
|
|
|
|
correlate activities across log files, alerting systems, etc.
|
|
|
|
|
|
|
|
There are two outputs. The `HH:MM:SS` output is simply for quick
|
|
|
|
human consumption. The epoch time retains more information, including
|
|
|
|
date, and is machine sortable if your recovery spans days.
|