---
type: api
title: Get index statistics
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-indices-stats
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-indices-stats
products:
  - Elasticsearch
---

# Get index statistics


Availability: Generally available since 1.3

## Paths

- `GET` `/{index}/_stats/{metric}`
- `GET` `/_stats/{metric}`
- `GET` `/{index}/_stats`
- `GET` `/_stats`

#### Path parameters

- `index` (union string | string[]) — optional, leave it out to use `/_stats`
  A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices
- `metric` (union string | string[]) — optional, leave it out to use `/_stats`
  Limit the information returned the specific metrics

## Description

For data streams, the API retrieves statistics for the stream's backing indices.

By default, the returned statistics are index-level with `primaries` and `total` aggregations.
`primaries` are the values for only the primary shards.
`total` are the accumulated values for both primary and replica shards.

To get shard-level statistics, set the `level` parameter to `shards`.

NOTE: When moving to another node, the shard-level statistics for a shard are cleared.
Although the shard is no longer part of the node, that node retains any node-level statistics to which the shard contributed.

## Required authorization

- Index privileges: `monitor`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## Query string parameters

- `completion_fields` (union oneOf) — optional
  Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics.
  One of: `string[]` or `string`
- `expand_wildcards` (string · default: open) — optional
  Type of index that wildcard patterns can match. If the request can target data streams, this argument
determines whether wildcard expressions match hidden data streams. Supports comma-separated values,
such as `open,hidden`.

Supported values include:
  - `all`: Match any data stream or index, including hidden ones.
  - `open`: Match open, non-hidden indices. Also matches any non-hidden data stream.
  - `closed`: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.
  - `hidden`: Match hidden data streams and hidden indices. Must be combined with `open`, `closed`, or `both`.
  - `none`: Wildcard expressions are not accepted.
  Values: `all`, `open`, `closed`, `hidden`, `none`
- `fielddata_fields` (union oneOf) — optional
  Comma-separated list or wildcard expressions of fields to include in fielddata statistics.
  One of: `string[]` or `string`
- `fields` (union oneOf) — optional
  Comma-separated list or wildcard expressions of fields to include in the statistics.
  One of: `string[]` or `string`
- `forbid_closed_indices` (boolean · default: true) — optional
  If true, statistics are not collected from closed indices.
- `groups` (union string | string[]) — optional
  Comma-separated list of search groups to include in the search statistics.
- `include_segment_file_sizes` (boolean · default: false) — optional
  If true, the call reports the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested).
- `include_unloaded_segments` (boolean · default: false) — optional
  If true, the response includes information from segments that are not loaded into memory.
- `level` (enum · default: indices) — optional
  Indicates whether statistics are aggregated at the cluster, indices, or shards level.
  Values: `cluster`, `indices`, `shards`

## Response

`application/json`

- `indices` (map string to object)
  Map values (object)
  - `primaries` (object)
    - `completion` (object)
      Contains statistics about completions across all shards assigned to the node.
      - `size_in_bytes` (number)
        Total amount, in bytes, of memory used for completion across all shards assigned to selected nodes.
      - `size` (number | string)
        Total amount of memory used for completion across all shards assigned to selected nodes.
      - `fields` (map string to object)
        Map values (object)
        - `size` (number | string)
        - `size_in_bytes` (number)
    - `docs` (object)
      Contains statistics about documents across all primary shards assigned to the node.
      - `count` (number)
        Total number of non-deleted documents across all primary shards assigned to selected nodes.
This number is based on documents in Lucene segments and may include documents from nested fields.
      - `deleted` (number)
        Total number of deleted documents across all primary shards assigned to selected nodes.
This number is based on documents in Lucene segments.
Elasticsearch reclaims the disk space of deleted Lucene documents when a segment is merged.
      - `total_size_in_bytes` (number)
        Returns the total size in bytes of all documents in this stats.
This value may be more reliable than store_stats.size_in_bytes in estimating the index size.
      - `total_size` (number | string)
        Human readable total_size_in_bytes
    - `fielddata` (object)
      Contains statistics about the field data cache across all shards assigned to the node.
      - `evictions` (number)
      - `memory_size` (number | string)
      - `memory_size_in_bytes` (number)
      - `fields` (map string to object)
        Map values (object)
        - `memory_size` (number | string)
        - `memory_size_in_bytes` (number)
      - `global_ordinals` (object)
        - `build_time_in_millis` (number)
        - `build_time` (string)
        - `fields` (map string to object)
          Map values (object)
          - `build_time_in_millis` (number)
          - `build_time` (string)
          - `shard_max_value_count` (number)
    - `flush` (object)
      Contains statistics about flush operations for the node.
      - `periodic` (number)
      - `total` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
    - `get` (object)
      Contains statistics about get operations for the node.
      - `current` (number)
      - `exists_time` (string)
      - `exists_time_in_millis` (number)
      - `exists_total` (number)
      - `missing_time` (string)
      - `missing_time_in_millis` (number)
      - `missing_total` (number)
      - `time` (string)
      - `time_in_millis` (number)
      - `total` (number)
    - `indexing` (object)
      Contains statistics about indexing operations for the node.
      - `index_current` (number)
      - `delete_current` (number)
      - `delete_time` (string)
      - `delete_time_in_millis` (number)
      - `delete_total` (number)
      - `is_throttled` (boolean)
      - `noop_update_total` (number)
      - `throttle_time` (string)
      - `throttle_time_in_millis` (number)
      - `index_time` (string)
      - `index_time_in_millis` (number)
      - `index_total` (number)
      - `index_failed` (number)
      - `types` (map string to object) — recursive
      - `write_load` (number)
    - `indices` (object) — recursive
      Contains statistics about indices operations for the node.
    - `merges` (object)
      Contains statistics about merge operations for the node.
      - `current` (number)
      - `current_docs` (number)
      - `current_size` (string)
      - `current_size_in_bytes` (number)
      - `total` (number)
      - `total_auto_throttle` (string)
      - `total_auto_throttle_in_bytes` (number)
      - `total_docs` (number)
      - `total_size` (string)
      - `total_size_in_bytes` (number)
      - `total_stopped_time` (string)
      - `total_stopped_time_in_millis` (number)
      - `total_throttled_time` (string)
      - `total_throttled_time_in_millis` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
    - `query_cache` (object)
      Contains statistics about the query cache across all shards assigned to the node.
      - `cache_count` (number)
        Total number of entries added to the query cache across all shards assigned to selected nodes.
This number includes current and evicted entries.
      - `cache_size` (number)
        Total number of entries currently in the query cache across all shards assigned to selected nodes.
      - `evictions` (number)
        Total number of query cache evictions across all shards assigned to selected nodes.
      - `hit_count` (number)
        Total count of query cache hits across all shards assigned to selected nodes.
      - `memory_size` (number | string)
        Total amount of memory used for the query cache across all shards assigned to selected nodes.
      - `memory_size_in_bytes` (number)
        Total amount, in bytes, of memory used for the query cache across all shards assigned to selected nodes.
      - `miss_count` (number)
        Total count of query cache misses across all shards assigned to selected nodes.
      - `total_count` (number)
        Total count of hits and misses in the query cache across all shards assigned to selected nodes.
    - `recovery` (object)
      Contains statistics about recovery operations for the node.
      - `current_as_source` (number)
      - `current_as_target` (number)
      - `throttle_time` (string)
      - `throttle_time_in_millis` (number)
    - `refresh` (object)
      Contains statistics about refresh operations for the node.
      - `external_total` (number)
      - `external_total_time_in_millis` (number)
      - `listeners` (number)
      - `total` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
    - `request_cache` (object)
      Contains statistics about the request cache across all shards assigned to the node.
      - `evictions` (number)
      - `hit_count` (number)
      - `memory_size` (string)
      - `memory_size_in_bytes` (number)
      - `miss_count` (number)
    - `search` (object)
      Contains statistics about search operations for the node.
      - `fetch_current` (number)
      - `fetch_time` (string)
      - `fetch_time_in_millis` (number)
      - `fetch_total` (number)
      - `open_contexts` (number)
      - `query_current` (number)
      - `query_time` (string)
      - `query_time_in_millis` (number)
      - `query_total` (number)
      - `scroll_current` (number)
      - `scroll_time` (string)
      - `scroll_time_in_millis` (number)
      - `scroll_total` (number)
      - `suggest_current` (number)
      - `suggest_time` (string)
      - `suggest_time_in_millis` (number)
      - `suggest_total` (number)
      - `groups` (map string to object) — recursive
    - `segments` (object)
      Contains statistics about segments across all shards assigned to the node.
      - `count` (number)
        Total number of segments across all shards assigned to selected nodes.
      - `doc_values_memory` (number | string)
        Total amount of memory used for doc values across all shards assigned to selected nodes.
      - `doc_values_memory_in_bytes` (number)
        Total amount, in bytes, of memory used for doc values across all shards assigned to selected nodes.
      - `file_sizes` (map string to object)
        This object is not populated by the cluster stats API.
To get information on segment files, use the node stats API.
        Map values (object)
        - `description` (string)
        - `size_in_bytes` (number)
        - `min_size_in_bytes` (number)
        - `max_size_in_bytes` (number)
        - `average_size_in_bytes` (number)
        - `count` (number)
      - `fixed_bit_set` (number | string)
        Total amount of memory used by fixed bit sets across all shards assigned to selected nodes.
Fixed bit sets are used for nested object field types and type filters for join fields.
      - `fixed_bit_set_memory_in_bytes` (number)
        Total amount of memory, in bytes, used by fixed bit sets across all shards assigned to selected nodes.
      - `index_writer_memory` (number | string)
        Total amount of memory used by all index writers across all shards assigned to selected nodes.
      - `index_writer_memory_in_bytes` (number)
        Total amount, in bytes, of memory used by all index writers across all shards assigned to selected nodes.
      - `max_unsafe_auto_id_timestamp` (number)
        Unix timestamp, in milliseconds, of the most recently retried indexing request.
      - `memory` (number | string)
        Total amount of memory used for segments across all shards assigned to selected nodes.
      - `memory_in_bytes` (number)
        Total amount, in bytes, of memory used for segments across all shards assigned to selected nodes.
      - `norms_memory` (number | string)
        Total amount of memory used for normalization factors across all shards assigned to selected nodes.
      - `norms_memory_in_bytes` (number)
        Total amount, in bytes, of memory used for normalization factors across all shards assigned to selected nodes.
      - `points_memory` (number | string)
        Total amount of memory used for points across all shards assigned to selected nodes.
      - `points_memory_in_bytes` (number)
        Total amount, in bytes, of memory used for points across all shards assigned to selected nodes.
      - `stored_fields_memory_in_bytes` (number)
        Total amount, in bytes, of memory used for stored fields across all shards assigned to selected nodes.
      - `stored_fields_memory` (number | string)
        Total amount of memory used for stored fields across all shards assigned to selected nodes.
      - `terms_memory_in_bytes` (number)
        Total amount, in bytes, of memory used for terms across all shards assigned to selected nodes.
      - `terms_memory` (number | string)
        Total amount of memory used for terms across all shards assigned to selected nodes.
      - `term_vectors_memory` (number | string)
        Total amount of memory used for term vectors across all shards assigned to selected nodes.
      - `term_vectors_memory_in_bytes` (number)
        Total amount, in bytes, of memory used for term vectors across all shards assigned to selected nodes.
      - `version_map_memory` (number | string)
        Total amount of memory used by all version maps across all shards assigned to selected nodes.
      - `version_map_memory_in_bytes` (number)
        Total amount, in bytes, of memory used by all version maps across all shards assigned to selected nodes.
    - `store` (object)
      Contains statistics about the size of shards assigned to the node.
      - `size` (number | string)
        Total size of all shards assigned to selected nodes.
      - `size_in_bytes` (number)
        Total size, in bytes, of all shards assigned to selected nodes.
      - `reserved` (number | string)
        A prediction of how much larger the shard stores will eventually grow due to ongoing peer recoveries, restoring snapshots, and similar activities.
      - `reserved_in_bytes` (number)
        A prediction, in bytes, of how much larger the shard stores will eventually grow due to ongoing peer recoveries, restoring snapshots, and similar activities.
      - `total_data_set_size` (number | string)
        Total data set size of all shards assigned to selected nodes.
This includes the size of shards not stored fully on the nodes, such as the cache for partially mounted indices.
      - `total_data_set_size_in_bytes` (number)
        Total data set size, in bytes, of all shards assigned to selected nodes.
This includes the size of shards not stored fully on the nodes, such as the cache for partially mounted indices.
    - `translog` (object)
      Contains statistics about transaction log operations for the node.
      - `earliest_last_modified_age` (number)
      - `operations` (number)
      - `size` (string)
      - `size_in_bytes` (number)
      - `uncommitted_operations` (number)
      - `uncommitted_size` (string)
      - `uncommitted_size_in_bytes` (number)
    - `warmer` (object)
      Contains statistics about index warming operations for the node.
      - `current` (number)
      - `total` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
    - `bulk` (object)
      - `total_operations` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
      - `total_size` (number | string)
      - `total_size_in_bytes` (number)
      - `avg_time` (string)
      - `avg_time_in_millis` (number)
      - `avg_size` (number | string)
      - `avg_size_in_bytes` (number)
    - `shard_stats` (object)
      - `total_count` (number)
  - `shards` (map string to object)
  - `total` (object)
    Same fields as `primaries` in `indices`
  - `uuid` (string)
  - `health` (enum)
    

Supported values include:
  - `green` (or `GREEN`): All shards are assigned.
  - `yellow` (or `YELLOW`): All primary shards are assigned, but one or more replica shards are unassigned. If a node in the cluster fails, some data could be unavailable until that node is repaired.
  - `red` (or `RED`): One or more primary shards are unassigned, so some data is unavailable. This can occur briefly during cluster startup as primary shards are assigned.
  - `unknown`
  - `unavailable`
    Values: `green`, `GREEN`, `yellow`, `YELLOW`, `red`, `RED`, `unknown`, `unavailable`
  - `status` (enum)
    Values: `open`, `close`
- `_shards` (object)
  - `failed` (number)
    The number of shards the operation or search attempted to run on but failed.
  - `successful` (number)
    The number of shards the operation or search succeeded on.
  - `total` (number)
    The number of shards the operation or search will run on overall.
  - `failures` (object[])
    - `index` (string)
    - `node` (string)
    - `reason` (object)
      - `type` (string)
        The type of error
      - `reason` (union string) — nullable
        A human-readable explanation of the error, in English.
        One of: `string`
      - `stack_trace` (string)
        The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
      - `caused_by` (object) — recursive
        Same fields as `reason` in `failures`
      - `root_cause` (object[]) — recursive
        Same fields as `reason` in `failures`
      - `suppressed` (object[]) — recursive
        Same fields as `reason` in `failures`
    - `shard` (number)
    - `status` (string)
    - `primary` (boolean)
  - `skipped` (number)
- `_all` (object)
  - `primaries` (object)
    - `completion` (object)
      Contains statistics about completions across all shards assigned to the node.
      - `size_in_bytes` (number)
        Total amount, in bytes, of memory used for completion across all shards assigned to selected nodes.
      - `size` (number | string)
        Total amount of memory used for completion across all shards assigned to selected nodes.
      - `fields` (map string to object)
        Map values (object)
        - `size` (number | string)
        - `size_in_bytes` (number)
    - `docs` (object)
      Contains statistics about documents across all primary shards assigned to the node.
      - `count` (number)
        Total number of non-deleted documents across all primary shards assigned to selected nodes.
This number is based on documents in Lucene segments and may include documents from nested fields.
      - `deleted` (number)
        Total number of deleted documents across all primary shards assigned to selected nodes.
This number is based on documents in Lucene segments.
Elasticsearch reclaims the disk space of deleted Lucene documents when a segment is merged.
      - `total_size_in_bytes` (number)
        Returns the total size in bytes of all documents in this stats.
This value may be more reliable than store_stats.size_in_bytes in estimating the index size.
      - `total_size` (number | string)
        Human readable total_size_in_bytes
    - `fielddata` (object)
      Contains statistics about the field data cache across all shards assigned to the node.
      Same fields as `fielddata` in `primaries`
    - `flush` (object)
      Contains statistics about flush operations for the node.
      - `periodic` (number)
      - `total` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
    - `get` (object)
      Contains statistics about get operations for the node.
      Same fields as `get` in `primaries`
    - `indexing` (object)
      Contains statistics about indexing operations for the node.
      Same fields as `indexing` in `primaries`
    - `indices` (object) — recursive
      Contains statistics about indices operations for the node.
      Same fields as `_all`
    - `merges` (object)
      Contains statistics about merge operations for the node.
      Same fields as `merges` in `primaries`
    - `query_cache` (object)
      Contains statistics about the query cache across all shards assigned to the node.
      - `cache_count` (number)
        Total number of entries added to the query cache across all shards assigned to selected nodes.
This number includes current and evicted entries.
      - `cache_size` (number)
        Total number of entries currently in the query cache across all shards assigned to selected nodes.
      - `evictions` (number)
        Total number of query cache evictions across all shards assigned to selected nodes.
      - `hit_count` (number)
        Total count of query cache hits across all shards assigned to selected nodes.
      - `memory_size` (number | string)
        Total amount of memory used for the query cache across all shards assigned to selected nodes.
      - `memory_size_in_bytes` (number)
        Total amount, in bytes, of memory used for the query cache across all shards assigned to selected nodes.
      - `miss_count` (number)
        Total count of query cache misses across all shards assigned to selected nodes.
      - `total_count` (number)
        Total count of hits and misses in the query cache across all shards assigned to selected nodes.
    - `recovery` (object)
      Contains statistics about recovery operations for the node.
      - `current_as_source` (number)
      - `current_as_target` (number)
      - `throttle_time` (string)
      - `throttle_time_in_millis` (number)
    - `refresh` (object)
      Contains statistics about refresh operations for the node.
      - `external_total` (number)
      - `external_total_time_in_millis` (number)
      - `listeners` (number)
      - `total` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
    - `request_cache` (object)
      Contains statistics about the request cache across all shards assigned to the node.
      - `evictions` (number)
      - `hit_count` (number)
      - `memory_size` (string)
      - `memory_size_in_bytes` (number)
      - `miss_count` (number)
    - `search` (object)
      Contains statistics about search operations for the node.
      Same fields as `search` in `primaries`
    - `segments` (object)
      Contains statistics about segments across all shards assigned to the node.
      Same fields as `segments` in `primaries`
    - `store` (object)
      Contains statistics about the size of shards assigned to the node.
      - `size` (number | string)
        Total size of all shards assigned to selected nodes.
      - `size_in_bytes` (number)
        Total size, in bytes, of all shards assigned to selected nodes.
      - `reserved` (number | string)
        A prediction of how much larger the shard stores will eventually grow due to ongoing peer recoveries, restoring snapshots, and similar activities.
      - `reserved_in_bytes` (number)
        A prediction, in bytes, of how much larger the shard stores will eventually grow due to ongoing peer recoveries, restoring snapshots, and similar activities.
      - `total_data_set_size` (number | string)
        Total data set size of all shards assigned to selected nodes.
This includes the size of shards not stored fully on the nodes, such as the cache for partially mounted indices.
      - `total_data_set_size_in_bytes` (number)
        Total data set size, in bytes, of all shards assigned to selected nodes.
This includes the size of shards not stored fully on the nodes, such as the cache for partially mounted indices.
    - `translog` (object)
      Contains statistics about transaction log operations for the node.
      - `earliest_last_modified_age` (number)
      - `operations` (number)
      - `size` (string)
      - `size_in_bytes` (number)
      - `uncommitted_operations` (number)
      - `uncommitted_size` (string)
      - `uncommitted_size_in_bytes` (number)
    - `warmer` (object)
      Contains statistics about index warming operations for the node.
      - `current` (number)
      - `total` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
    - `bulk` (object)
      - `total_operations` (number)
      - `total_time` (string)
      - `total_time_in_millis` (number)
      - `total_size` (number | string)
      - `total_size_in_bytes` (number)
      - `avg_time` (string)
      - `avg_time_in_millis` (number)
      - `avg_size` (number | string)
      - `avg_size_in_bytes` (number)
    - `shard_stats` (object)
      - `total_count` (number)
  - `shards` (map string to object)
  - `total` (object)
    Same fields as `primaries` in `_all`
  - `uuid` (string)
  - `health` (enum)
    

Supported values include:
  - `green` (or `GREEN`): All shards are assigned.
  - `yellow` (or `YELLOW`): All primary shards are assigned, but one or more replica shards are unassigned. If a node in the cluster fails, some data could be unavailable until that node is repaired.
  - `red` (or `RED`): One or more primary shards are unassigned, so some data is unavailable. This can occur briefly during cluster startup as primary shards are assigned.
  - `unknown`
  - `unavailable`
    Values: `green`, `GREEN`, `yellow`, `YELLOW`, `red`, `RED`, `unknown`, `unavailable`
  - `status` (enum)
    Values: `open`, `close`
## Code examples

#### Console

```console
GET _stats/fielddata?human&fields=my_join_field#question
```

#### JavaScript

```javascript
const response = await client.indices.stats({
  metric: "fielddata",
  human: "true",
  fields: "my_join_field",
});
```

#### Python

```python
resp = client.indices.stats(
    metric="fielddata",
    human=True,
    fields="my_join_field",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_stats/fielddata?human&fields=my_join_field#question" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java

```

#### C#

```c#
var response = await client.Indices
    .StatsAsync(d1 => d1
        .Metric("fielddata")
        .Fields(x => x.MyJoinField)
    );
```

#### PHP

```php
$resp = $client->indices()->stats([
    "metric" => "fielddata",
    "human" => "true",
    "fields" => "my_join_field",
]);
```

#### Ruby

```ruby
response = client.indices.stats(
  metric: "fielddata",
  human: "true",
  fields: "my_join_field"
)
```

