OpenSearch/docs/reference/indices/stats.asciidoc

144 lines
3.5 KiB
Plaintext

[[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 /twitter/_stats
----
// TEST[setup:twitter]
[[index-stats-api-request]]
==== {api-request-title}
`GET /<target>/_stats/<index-metric>`
`GET /<target>/_stats`
`GET /_stats`
[[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 index aliases used to limit
the request. Wildcard expressions (`*`) are supported.
+
To target all data streams and indices in a cluster, omit this parameter or use
`_all` or `*`.
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-metric]
[[index-stats-api-query-params]]
==== {api-query-parms-title}
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
+
Defaults to `open`.
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=fields]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=completion-fields]
include::{es-repo-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-repo-dir}/rest-api/common-parms.asciidoc[tag=groups]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=level]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes]
include::{es-repo-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:twitter]
[[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:twitter]
[[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:twitter]