2013-08-28 19:24:34 -04:00
|
|
|
[[indices-stats]]
|
2019-09-05 15:03:33 -04:00
|
|
|
=== Index stats API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Index stats</titleabbrev>
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
Returns statistics for one or more indices. For data streams, the API retrieves
|
|
|
|
statistics for the stream's backing indices.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
[source,console]
|
|
|
|
----
|
2020-07-31 09:51:47 -04:00
|
|
|
GET /my-index-000001/_stats
|
2019-09-05 15:03:33 -04:00
|
|
|
----
|
2020-07-31 09:51:47 -04:00
|
|
|
// TEST[setup:my_index]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
[[index-stats-api-request]]
|
|
|
|
==== {api-request-title}
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
`GET /<target>/_stats/<index-metric>`
|
2019-09-05 15:03:33 -04:00
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
`GET /<target>/_stats`
|
2019-09-05 15:03:33 -04:00
|
|
|
|
|
|
|
`GET /_stats`
|
|
|
|
|
|
|
|
|
|
|
|
[[index-stats-api-desc]]
|
|
|
|
==== {api-description-title}
|
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
Use the index stats API to get high-level aggregation and statistics for one or
|
|
|
|
more data streams and indices.
|
2019-09-05 15:03:33 -04:00
|
|
|
|
|
|
|
By default,
|
|
|
|
the returned statistics are index-level
|
|
|
|
with `primaries` and `total` aggregations.
|
Deprecate REST access to System Indices (#63274) (Original #60945)
This PR adds deprecation warnings when accessing System Indices via the REST layer. At this time, these warnings are only enabled for Snapshot builds by default, to allow projects external to Elasticsearch additional time to adjust their access patterns.
Deprecation warnings will be triggered by all REST requests which access registered System Indices, except for purpose-specific APIs which access System Indices as an implementation detail a few specific APIs which will continue to allow access to system indices by default:
- `GET _cluster/health`
- `GET {index}/_recovery`
- `GET _cluster/allocation/explain`
- `GET _cluster/state`
- `POST _cluster/reroute`
- `GET {index}/_stats`
- `GET {index}/_segments`
- `GET {index}/_shard_stores`
- `GET _cat/[indices,aliases,health,recovery,shards,segments]`
Deprecation warnings for accessing system indices take the form:
```
this request accesses system indices: [.some_system_index], but in a future major version, direct access to system indices will be prevented by default
```
2020-10-06 15:41:40 -04:00
|
|
|
`primaries` are the values for only the primary shards.
|
2019-09-05 15:03:33 -04:00
|
|
|
`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.
|
|
|
|
====
|
|
|
|
|
|
|
|
|
|
|
|
[[index-stats-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
`<target>`::
|
|
|
|
(Optional, string)
|
|
|
|
Comma-separated list of data streams, indices, and index aliases used to limit
|
|
|
|
the request. Wildcard expressions (`*`) are supported.
|
2019-09-05 15:03:33 -04:00
|
|
|
+
|
2020-07-13 09:05:03 -04:00
|
|
|
To target all data streams and indices in a cluster, omit this parameter or use
|
|
|
|
`_all` or `*`.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-metric]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
[[index-stats-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2019-09-05 15:03:33 -04:00
|
|
|
+
|
|
|
|
Defaults to `open`.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=fields]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=completion-fields]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=fielddata-fields]
|
2016-02-19 16:25:42 -05:00
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
`forbid_closed_indices`::
|
|
|
|
(Optional, boolean)
|
|
|
|
If `true`, statistics are *not* collected from closed indices.
|
|
|
|
Defaults to `true`.
|
2014-08-06 05:54:51 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=groups]
|
2013-09-16 04:21:25 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=level]
|
2014-08-06 05:54:51 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes]
|
2014-08-06 05:54:51 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments]
|
2014-08-06 05:54:51 -04:00
|
|
|
|
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
[[index-stats-api-example]]
|
|
|
|
==== {api-examples-title}
|
2014-08-06 05:54:51 -04:00
|
|
|
|
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
[[index-stats-api-multiple-ex]]
|
2020-07-13 09:05:03 -04:00
|
|
|
===== Get statistics for multiple data streams and indices
|
2013-09-16 04:21:25 -04:00
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
|
|
|
GET /index1,index2/_stats
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[s/^/PUT index1\nPUT index2\n/]
|
|
|
|
|
|
|
|
|
|
|
|
[[index-stats-api-all-ex]]
|
2020-07-13 09:05:03 -04:00
|
|
|
===== Get statistics for all data streams and indices in a cluster
|
2019-09-05 15:03:33 -04:00
|
|
|
|
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
|
|
|
GET /_stats
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
// TEST[setup:my_index]
|
2019-09-05 15:03:33 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[index-stats-api-specific-stats-ex]]
|
|
|
|
===== Get specific statistics
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
The following request returns
|
|
|
|
only the `merge` and `refresh` statistics
|
|
|
|
for all indices.
|
|
|
|
|
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2016-09-02 18:22:30 -04:00
|
|
|
GET /_stats/merge,refresh
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
// TEST[setup:my_index]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2015-06-19 10:47:15 -04:00
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
[[index-stats-api-specific-groups-ex]]
|
|
|
|
===== Get statistics for specific search groups
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-05 15:03:33 -04:00
|
|
|
The following request returns
|
|
|
|
only search statistics
|
|
|
|
for the `group1` and `group2` search groups.
|
|
|
|
|
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
|
|
|
GET /_stats/search?groups=group1,group2
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
// TEST[setup:my_index]
|