elasticsearch,

How to check Elasticsearch cluster health

Aug 30, 2021 · 1 min read · Post a comment

Knowing how to get statistics and understand the output from an Elasticsearch cluster can be very useful for a DevOps guy. This tutorial is aimed to show you how to check Elasticsearch cluster health.

Prerequisites

  • Elasticsearch cluster

Check Elasticsearch Cluster health

Step 1. To get the Elasticsearch cluster health, run:

curl -XGET 'ES_Endpoint/_cluster/health'

Output:

{
  "cluster_name" : "devcoops-cluster",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 4,
  "number_of_data_nodes" : 2,
  "discovered_master" : true,
  "active_primary_shards" : 277,
  "active_shards" : 332,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "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" : 100.0
}s

The interesting part is the status field. It can provide you with indication of how the cluster is behaving:

  • green: All primary and replica shards are active.
  • yellow: Primary shards are active, but not all replica shards are active.
  • red: Last but not least red status tells you that not all primary shards are active.

Conclusion

Seemingly it looks easy, but it’s very important to understand the info from the status field if you have to investigate some cluster issues. Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.