Elasticsearch List Indices and Size

Having up-to-date information about your devices can help troubleshoot and manage your system. Knowing this, Elasticsearch provides simple ways to display elaborate statistics about indices in your cluster.

This tutorial discusses the art of using Elasticsearch CAT API to view detailed information about indices in the cluster. This information should help you manage how the clusters are performing and what actions to take.

You may already know that Elasticsearch loves JSON and uses it for all its APIs. However, displayed information or data is only useful to you when it’s in a simple, well-organized form; JSON might not accomplish this very well. Thus, Elasticsearch does not recommend using CAT API with applications but for human reading only.

With that out of the way, let’s dive in!

How to View High-Level Information about Indices?

To get high-level information about an Elasticsearch index, we use the_cat API. For example, to view information about a specific cluster, use the command:

GET /_cat/indices/<target>

You can also use the cRUL command:

curl -XGET “http://localhost:9200/_cat/indices/<index name>”

Once you execute the request above, you will get information about the specified index. This information may include:

  • Number of shards
  • Documents available in the index
  • Number of deleted documents in the index
  • The primary size
  • The total size of all the index shards (replicas included)

The _cat API can also fetch high-level information about all indices in a cluster, for example:

GET /_cat/indices

For cURL users, enter the command:

curl -XGET “http://localhost:9200/_cat/indices”

This should display information about all indices in the cluster, as shown below:

green open .siem-signals-default-000001         YFRPjV8wQju_ZZupE1s12g 1 1      0     0    416b    208b
green open .monitoring-beats-7-2021.01.21            iQZnVRaNQg-m7lkeEKA8Bw 1 1   3990     0     7mb   3.4mb
green open elastic-cloud-logs-7-2021.01.20-000001    cAVZV5d1RA-GeonwMej5nA 1 1 121542     0  43.4mb  21.4mb
green open .triggered_watches                        FyLc7T7wSxSW9roVJxyiPA 1 1      0     0 518.7kb  30.1kb
green open apm-7.10.2-onboarding-2021.01.20          zz-RRPjXQ1WGZIrRiqsLOQ 1 1      2     0  29.4kb  14.7kb
green open kibana_sample_data_flights                9nA2U3m7QX2g9u_JUFsgXQ 1 1  13059     0  10.6mb   5.3mb
green open .monitoring-kibana-7-2021.01.21           WiGi5NaaTdyUUyKSBgNx9w 1 1   6866     0   3.1mb   1.7mb
green open .monitoring-beats-7-2021.01.20            1Lx1vaQdTx2lEevMH1N3lg 1 1   4746     0     8mb     4mb
————————————OUTPUT TRUNCATED————————-

How to Filter Required Information?

In most cases, you will only need specific information about indices. To accomplish this, you can use _cat API parameters.

For example, to get only the UUID of the index, size, and health status, you can use the h parameter to accomplish this. For example, consider the request below:

GET /_cat/indices?v=true&h=uuid,health,store.size

The cURL command for this example is:

curl -XGET “http://localhost:9200/_cat/indices?v=true&h=uuid,health,store.size”

That should display filtered information for all indices in the cluster. Here’s an example output:

uuid                   health store.size
YFRPjV8wQju_ZZupE1s12g green        416b
iQZnVRaNQg-m7lkeEKA8Bw green       7.1mb
cAVZV5d1RA-GeonwMej5nA green      44.1mb
FyLc7T7wSxSW9roVJxyiPA green     518.7kb
zz-RRPjXQ1WGZIrRiqsLOQ green      29.4kb
9nA2U3m7QX2g9u_JUFsgXQ green      10.6mb
WiGi5NaaTdyUUyKSBgNx9w green       3.9mb
QdXSZTY8TA2mDyJ5INSaHg green       2.8mb
1Lx1vaQdTx2lEevMH1N3lg green         8mb
aBlLAWhPRXap32EqrKMPXA green      67.7kb
Bg2VT1QpT4CSjnwe1hnq_w green        416b
aoWhhWu9QsWW4T5CY_XWZw green        416b
6SAhoYJaS_6y_u8AZ0m3KQ green        416b
Wco9drGpSn67zYME6wFCEQ green     485.5kb
eN2loWymSpqLlC2-ElYm1Q green        416b
K5C9TeLcSy69SsUdtkyGOg green      40.2kb
bUDul_72Rw6_9hWMagiSFQ green       3.1mb
c7dOH6MQQUmHM2MKJ73ekw green        416b
aoTRvqdfR8-dGjCmcKSmjw green      48.9kb
IG7n9JghR1ikeCk7BqlaqA green        416b
BWAbxK06RoOSmL_KiPe09w green      12.5kb
feAUC7k2RiKrEws9iveZ0w green       4.6mb
F73wTiN2TUiAVcm2giAUJA green        416b
hlhLemJ5SnmiQUPYU2gQuA green        416b
jbUeUWFfR6y2TKb-6tEh6g green        416b
2ZyqPCAaTia0ydcy2jZd3A green     304.5kb
———————————OUTPUT TRUNCATED—————————-

How to Get All Index Metrics?

Suppose you want detailed statistics for a specific index. In such cases, you can use the _stats endpoint to query the data. For example, to get detailed information about an index called temp_2, use the request:

GET /temp_2/_stats

You can also use cURL as:

curl -XGET “http://localhost:9200/temp_2/_stats”

An example statistic information should be as shown below:

  “_shards” : {
    “total” : 2,
    “successful” : 2,
    “failed” : 0
  “_all” : {
    “primaries” : {
      “docs” : {
        “count” : 0,
        “deleted” : 0
      “store” : {
        “size_in_bytes” : 208,
        “reserved_in_bytes” : 0
      “indexing” : {
        “index_total” : 0,
        “index_time_in_millis” : 0,
        “index_current” : 0,
        “index_failed” : 0,
        “delete_total” : 0,
        “delete_time_in_millis” : 0,
        “delete_current” : 0,
        “noop_update_total” : 0,
        “is_throttled” : false,
        “throttle_time_in_millis” : 0
      “get” : {
        “total” : 0,
        “time_in_millis” : 0,
        “exists_total” : 0,
        “exists_time_in_millis” : 0,
        “missing_total” : 0,
        “missing_time_in_millis” : 0,
        “current” : 0
—————————–OUTPUT TRUNCATED——————————


In this quick tutorial, we have learned how to use Elasticsearch API to get information about single or multiple indices within a cluster. We also learned how to filter data to get only the required values. You can learn more by checking the _cat and _stats API.

For more Elasticsearch tutorials, search the site.

Thank you for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *