|
1 | 1 | [[indices-stats]] |
2 | | -=== Indices Stats |
| 2 | +=== Index stats API |
| 3 | +++++ |
| 4 | +<titleabbrev>Index stats</titleabbrev> |
| 5 | +++++ |
3 | 6 |
|
4 | | -Indices level stats provide statistics on different operations happening |
5 | | -on an index. The API provides statistics on the index level scope |
6 | | -(though most stats can also be retrieved using node level scope). |
| 7 | +Returns statistics for an index. |
7 | 8 |
|
8 | | -The following returns high level aggregation and index level stats for |
9 | | -all indices: |
| 9 | +[source,console] |
| 10 | +---- |
| 11 | +GET /twitter/_stats |
| 12 | +---- |
| 13 | +// TEST[setup:twitter] |
10 | 14 |
|
11 | | -[source,js] |
12 | | --------------------------------------------------- |
13 | | -GET /_stats |
14 | | --------------------------------------------------- |
15 | | -// CONSOLE |
16 | 15 |
|
17 | | -Specific index stats can be retrieved using: |
| 16 | +[[index-stats-api-request]] |
| 17 | +==== {api-request-title} |
18 | 18 |
|
19 | | -[source,js] |
20 | | --------------------------------------------------- |
21 | | -GET /index1,index2/_stats |
22 | | --------------------------------------------------- |
23 | | -// CONSOLE |
24 | | -// TEST[s/^/PUT index1\nPUT index2\n/] |
| 19 | +`GET /<index>/_stats/<index-metric>` |
| 20 | + |
| 21 | +`GET /<index>/_stats` |
| 22 | + |
| 23 | +`GET /_stats` |
| 24 | + |
| 25 | + |
| 26 | +[[index-stats-api-desc]] |
| 27 | +==== {api-description-title} |
| 28 | + |
| 29 | +Use the index stats API to get high-level aggregation and statistics for an index. |
| 30 | + |
| 31 | +By default, |
| 32 | +the returned statistics are index-level |
| 33 | +with `primaries` and `total` aggregations. |
| 34 | +`primaries` are the values for only the primary shards. |
| 35 | +`total` are the accumulated values for both primary and replica shards. |
| 36 | + |
| 37 | +To get shard-level statistics, |
| 38 | +set the `level` parameter to `shards`. |
| 39 | + |
| 40 | +[NOTE] |
| 41 | +==== |
| 42 | +When moving to another node, |
| 43 | +the shard-level statistics for a shard are cleared. |
| 44 | +Although the shard |
| 45 | +is no longer part of the node, |
| 46 | +that node retains any node-level statistics |
| 47 | +to which the shard contributed. |
| 48 | +==== |
| 49 | + |
| 50 | + |
| 51 | +[[index-stats-api-path-params]] |
| 52 | +==== {api-path-parms-title} |
| 53 | + |
| 54 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=index] |
| 55 | ++ |
| 56 | +To retrieve statistics for all indices, |
| 57 | +use a value of `_all` or `*` or omit this parameter. |
25 | 58 |
|
26 | | -By default, all stats are returned, returning only specific stats can be |
27 | | -specified as well in the URI. Those stats can be any of: |
| 59 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=index-metric] |
28 | 60 |
|
29 | | -[horizontal] |
30 | | -`docs`:: The number of docs / deleted docs (docs not yet merged out). |
31 | | - Note, affected by refreshing the index. |
32 | 61 |
|
33 | | -`store`:: The size of the index. |
| 62 | +[[index-stats-api-query-params]] |
| 63 | +==== {api-query-parms-title} |
34 | 64 |
|
35 | | -`indexing`:: Indexing statistics, can be combined with a comma |
36 | | - separated list of `types` to provide document type level stats. |
| 65 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards] |
| 66 | ++ |
| 67 | +Defaults to `open`. |
37 | 68 |
|
38 | | -`get`:: Get statistics, including missing stats. |
| 69 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=fields] |
39 | 70 |
|
40 | | -`search`:: Search statistics including suggest statistics. |
41 | | - You can include statistics for custom groups by adding |
42 | | - an extra `groups` parameter (search operations can be associated with one or more |
43 | | - groups). The `groups` parameter accepts a comma separated list of group names. |
44 | | - Use `_all` to return statistics for all groups. |
| 71 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=completion-fields] |
45 | 72 |
|
46 | | -`segments`:: Retrieve the memory use of the open segments. Optionally, setting the `include_segment_file_sizes` flag, report the aggregated disk usage of each one of the Lucene index files. |
| 73 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=fielddata-fields] |
47 | 74 |
|
48 | | -`completion`:: Completion suggest statistics. |
49 | | -`fielddata`:: Fielddata statistics. |
50 | | -`flush`:: Flush statistics. |
51 | | -`merge`:: Merge statistics. |
52 | | -`request_cache`:: <<shard-request-cache,Shard request cache>> statistics. |
53 | | -`refresh`:: Refresh statistics. |
54 | | -`warmer`:: Warmer statistics. |
55 | | -`translog`:: Translog statistics. |
| 75 | +`forbid_closed_indices`:: |
| 76 | +(Optional, boolean) |
| 77 | +If `true`, statistics are *not* collected from closed indices. |
| 78 | +Defaults to `true`. |
56 | 79 |
|
57 | | -Some statistics allow per field granularity which accepts a list |
58 | | -comma-separated list of included fields. By default all fields are included: |
| 80 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=groups] |
59 | 81 |
|
60 | | -[horizontal] |
61 | | -`fields`:: |
| 82 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=level] |
62 | 83 |
|
63 | | - List of fields to be included in the statistics. This is used as the |
64 | | - default list unless a more specific field list is provided (see below). |
| 84 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes] |
65 | 85 |
|
66 | | -`completion_fields`:: |
| 86 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments] |
67 | 87 |
|
68 | | - List of fields to be included in the Completion Suggest statistics. |
69 | 88 |
|
70 | | -`fielddata_fields`:: |
| 89 | +[[index-stats-api-example]] |
| 90 | +==== {api-examples-title} |
71 | 91 |
|
72 | | - List of fields to be included in the Fielddata statistics. |
73 | 92 |
|
| 93 | +[[index-stats-api-multiple-ex]] |
| 94 | +===== Get statistics for multiple indices |
74 | 95 |
|
75 | | -Here are some samples: |
| 96 | +[source,console] |
| 97 | +-------------------------------------------------- |
| 98 | +GET /index1,index2/_stats |
| 99 | +-------------------------------------------------- |
| 100 | +// TEST[s/^/PUT index1\nPUT index2\n/] |
| 101 | + |
| 102 | + |
| 103 | +[[index-stats-api-all-ex]] |
| 104 | +===== Get statistics for all indices |
| 105 | + |
| 106 | +[source,console] |
| 107 | +-------------------------------------------------- |
| 108 | +GET /_stats |
| 109 | +-------------------------------------------------- |
| 110 | +// TEST[setup:twitter] |
| 111 | + |
| 112 | + |
| 113 | +[[index-stats-api-specific-stats-ex]] |
| 114 | +===== Get specific statistics |
76 | 115 |
|
77 | | -[source,js] |
| 116 | +The following request returns |
| 117 | +only the `merge` and `refresh` statistics |
| 118 | +for all indices. |
| 119 | + |
| 120 | +[source,console] |
78 | 121 | -------------------------------------------------- |
79 | | -# Get back stats for merge and refresh only for all indices |
80 | 122 | GET /_stats/merge,refresh |
81 | | -# Get back stats for type1 and type2 documents for the my_index index |
82 | | -GET /my_index/_stats/indexing?types=type1,type2 |
83 | | -# Get back just search stats for group1 and group2 |
84 | | -GET /_stats/search?groups=group1,group2 |
85 | 123 | -------------------------------------------------- |
86 | | -// CONSOLE |
87 | | -// TEST[s/^/PUT my_index\n/] |
| 124 | +// TEST[setup:twitter] |
88 | 125 |
|
89 | | -The stats returned are aggregated on the index level, with |
90 | | -`primaries` and `total` aggregations, where `primaries` are the values for only the |
91 | | -primary shards, and `total` are the accumulated values for both primary and replica shards. |
92 | 126 |
|
93 | | -In order to get back shard level stats, set the `level` parameter to `shards`. |
| 127 | +[[index-stats-api-specific-groups-ex]] |
| 128 | +===== Get statistics for specific search groups |
94 | 129 |
|
95 | | -Note, as shards move around the cluster, their stats will be cleared as |
96 | | -they are created on other nodes. On the other hand, even though a shard |
97 | | -"left" a node, that node will still retain the stats that shard |
98 | | -contributed to. |
| 130 | +The following request returns |
| 131 | +only search statistics |
| 132 | +for the `group1` and `group2` search groups. |
| 133 | + |
| 134 | +[source,console] |
| 135 | +-------------------------------------------------- |
| 136 | +GET /_stats/search?groups=group1,group2 |
| 137 | +-------------------------------------------------- |
| 138 | +// TEST[setup:twitter] |
0 commit comments