OpenSearch/docs/reference/indices/stats.asciidoc

139 lines
3.2 KiB
Plaintext
Raw Normal View History

[[indices-stats]]
=== Index stats API
++++
<titleabbrev>Index stats</titleabbrev>
++++
Returns statistics for an index.
[source,console]
----
GET /twitter/_stats
----
// TEST[setup:twitter]
[[index-stats-api-request]]
==== {api-request-title}
`GET /<index>/_stats/<index-metric>`
`GET /<index>/_stats`
`GET /_stats`
[[index-stats-api-desc]]
==== {api-description-title}
Use the index stats API to get high-level aggregation and statistics for an index.
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}
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
+
To retrieve statistics for all indices,
use a value of `_all` or `*` or omit this parameter.
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-metric]
[[index-stats-api-query-params]]
==== {api-query-parms-title}
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
+
Defaults to `open`.
include::{docdir}/rest-api/common-parms.asciidoc[tag=fields]
include::{docdir}/rest-api/common-parms.asciidoc[tag=completion-fields]
include::{docdir}/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::{docdir}/rest-api/common-parms.asciidoc[tag=groups]
include::{docdir}/rest-api/common-parms.asciidoc[tag=level]
include::{docdir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes]
include::{docdir}/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 indices
[source,console]
--------------------------------------------------
GET /index1,index2/_stats
--------------------------------------------------
// TEST[s/^/PUT index1\nPUT index2\n/]
[[index-stats-api-all-ex]]
===== Get statistics for all indices
[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]