Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get replica number of an elasticserach cluster

I have a Elasticsearch instance running on AWS. Below is the cluster health data:

{
  "cluster_name": "553479592532:test-perf",
  "status": "yellow",
  "timed_out": false,
  "number_of_nodes": 1,
  "number_of_data_nodes": 1,
  "active_primary_shards": 6,
  "active_shards": 6,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 5,
  "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": 54.54545454545454
}

From the above output, I can see that there are 1 node and 6 shards. 6 shards have been assigned to the node and there are 5 unassigned shards. But how can I know the number of replicas?

like image 327
Joey Yi Zhao Avatar asked Sep 07 '25 10:09

Joey Yi Zhao


1 Answers

You can use the indices api, which would list all the indices in your cluster and their primary and replica shards. As your number of primary shards are already small, hence you won't even get the huge number of indices in your cluster.

API := http://localhost:9200/_cat/indices?v, here replace localhost with your elastic host.

Edit: Response provide by OP is from cluster health API , and according to docs, And according to official ES docs:

active_primary_shards(integer): The number of active primary shards.

active_shards(integer): The total number of active primary and replica shards.

I also tested this locally and it works fine, by looking at active_shards, its clear that you don't have any replica shards.. You can basically subtract the value of active_primary_shards from active_shards.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!