elasticsearch/docs/reference/indices/stats.asciidoc
Liam Thompson 33a71e3289
[DOCS] Refactor book-scoped variables in docs/reference/index.asciidoc (#107413)
* Remove `es-test-dir` book-scoped variable

* Remove `plugins-examples-dir` book-scoped variable

* Remove `:dependencies-dir:` and `:xes-repo-dir:` book-scoped variables

- In `index.asciidoc`, two variables (`:dependencies-dir:` and `:xes-repo-dir:`) were removed.
- In `sql/index.asciidoc`, the `:sql-tests:` path was updated to fuller path
- In `esql/index.asciidoc`, the `:esql-tests:` path was updated idem

* Replace `es-repo-dir` with `es-ref-dir`

* Move `:include-xpack: true` to few files that use it, remove from index.asciidoc
2024-04-17 14:37:07 +02:00

146 lines
3.7 KiB
Text

[[indices-stats]]
=== Index stats API
++++
<titleabbrev>Index stats</titleabbrev>
++++
Returns statistics for one or more indices. For data streams, the API retrieves
statistics for the stream's backing indices.
[source,console]
----
GET /my-index-000001/_stats
----
// TEST[setup:my_index]
[[index-stats-api-request]]
==== {api-request-title}
`GET /<target>/_stats/<index-metric>`
`GET /<target>/_stats`
`GET /_stats`
[[index-stats-api-prereqs]]
==== {api-prereq-title}
* If the {es} {security-features} are enabled, you must have the `monitor` or
`manage` <<privileges-list-indices,index privilege>> for the target data stream,
index, or alias.
[[index-stats-api-desc]]
==== {api-description-title}
Use the index stats API to get high-level aggregation and statistics for one or
more data streams and 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.
====
[[index-stats-api-path-params]]
==== {api-path-parms-title}
`<target>`::
(Optional, string) Comma-separated list of data streams, indices, and aliases
used to limit the request. Supports wildcards (`*`). To target all data streams
and indices, omit this parameter or use `*` or `_all`.
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=index-metric]
[[index-stats-api-query-params]]
==== {api-query-parms-title}
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
+
Defaults to `open`.
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=fields]
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=completion-fields]
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=fielddata-fields]
`forbid_closed_indices`::
(Optional, Boolean)
If `true`, statistics are *not* collected from closed indices.
Defaults to `true`.
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=groups]
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=level]
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes]
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments]
[[index-stats-api-example]]
==== {api-examples-title}
[[index-stats-api-multiple-ex]]
===== Get statistics for multiple data streams and indices
[source,console]
--------------------------------------------------
GET /index1,index2/_stats
--------------------------------------------------
// TEST[s/^/PUT index1\nPUT index2\n/]
[[index-stats-api-all-ex]]
===== Get statistics for all data streams and indices in a cluster
[source,console]
--------------------------------------------------
GET /_stats
--------------------------------------------------
// TEST[setup:my_index]
[[index-stats-api-specific-stats-ex]]
===== Get specific statistics
The following request returns
only the `merge` and `refresh` statistics
for all indices.
[source,console]
--------------------------------------------------
GET /_stats/merge,refresh
--------------------------------------------------
// TEST[setup:my_index]
[[index-stats-api-specific-groups-ex]]
===== Get statistics for specific search groups
The following request returns
only search statistics
for the `group1` and `group2` search groups.
[source,console]
--------------------------------------------------
GET /_stats/search?groups=group1,group2
--------------------------------------------------
// TEST[setup:my_index]