|
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 |
| - |
8 |
| -The following returns high level aggregation and index level stats for |
9 |
| -all indices: |
| 7 | +Returns statistics for an index. |
10 | 8 |
|
11 | 9 | [source,js]
|
12 |
| --------------------------------------------------- |
13 |
| -GET /_stats |
14 |
| --------------------------------------------------- |
| 10 | +---- |
| 11 | +GET /twitter/_stats |
| 12 | +---- |
15 | 13 | // CONSOLE
|
| 14 | +// TEST[setup:twitter] |
16 | 15 |
|
17 |
| -Specific index stats can be retrieved using: |
18 | 16 |
|
19 |
| -[source,js] |
20 |
| --------------------------------------------------- |
21 |
| -GET /index1,index2/_stats |
22 |
| --------------------------------------------------- |
23 |
| -// CONSOLE |
24 |
| -// TEST[s/^/PUT index1\nPUT index2\n/] |
| 17 | +[[index-stats-api-request]] |
| 18 | +==== {api-request-title} |
| 19 | + |
| 20 | +`GET /<index>/_stats/<index-metric>` |
| 21 | + |
| 22 | +`GET /<index>/_stats` |
| 23 | + |
| 24 | +`GET /_stats` |
| 25 | + |
| 26 | + |
| 27 | +[[index-stats-api-desc]] |
| 28 | +==== {api-description-title} |
| 29 | + |
| 30 | +Use the index stats API to get high-level aggregation and statistics for an index. |
| 31 | + |
| 32 | +By default, |
| 33 | +the returned statistics are index-level |
| 34 | +with `primaries` and `total` aggregations. |
| 35 | +`primaries` are the values for only the primary shards. |
| 36 | +`total` are the accumulated values for both primary and replica shards. |
| 37 | + |
| 38 | +To get shard-level statistics, |
| 39 | +set the `level` parameter to `shards`. |
| 40 | + |
| 41 | +[NOTE] |
| 42 | +==== |
| 43 | +When moving to another node, |
| 44 | +the shard-level statistics for a shard are cleared. |
| 45 | +Although the shard |
| 46 | +is no longer part of the node, |
| 47 | +that node retains any node-level statistics |
| 48 | +to which the shard contributed. |
| 49 | +==== |
| 50 | + |
| 51 | + |
| 52 | +[[index-stats-api-path-params]] |
| 53 | +==== {api-path-parms-title} |
| 54 | + |
| 55 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=index] |
| 56 | ++ |
| 57 | +To retrieve statistics for all indices, |
| 58 | +use a value of `_all` or `*` or omit this parameter. |
| 59 | + |
| 60 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=index-metric] |
25 | 61 |
|
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: |
28 | 62 |
|
29 |
| -[horizontal] |
30 |
| -`docs`:: The number of docs / deleted docs (docs not yet merged out). |
31 |
| - Note, affected by refreshing the index. |
| 63 | +[[index-stats-api-query-params]] |
| 64 | +==== {api-query-parms-title} |
32 | 65 |
|
33 |
| -`store`:: The size of the index. |
| 66 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards] |
| 67 | ++ |
| 68 | +Defaults to `open`. |
34 | 69 |
|
35 |
| -`indexing`:: Indexing statistics, can be combined with a comma |
36 |
| - separated list of `types` to provide document type level stats. |
| 70 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=fields] |
37 | 71 |
|
38 |
| -`get`:: Get statistics, including missing stats. |
| 72 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=completion-fields] |
39 | 73 |
|
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. |
| 74 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=fielddata-fields] |
45 | 75 |
|
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. |
| 76 | +`forbid_closed_indices`:: |
| 77 | +(Optional, boolean) |
| 78 | +If `true`, statistics are *not* collected from closed indices. |
| 79 | +Defaults to `true`. |
47 | 80 |
|
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. |
| 81 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=groups] |
56 | 82 |
|
57 |
| -Some statistics allow per field granularity which accepts a list |
58 |
| -comma-separated list of included fields. By default all fields are included: |
| 83 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=level] |
59 | 84 |
|
60 |
| -[horizontal] |
61 |
| -`fields`:: |
| 85 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes] |
62 | 86 |
|
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). |
| 87 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments] |
65 | 88 |
|
66 |
| -`completion_fields`:: |
67 | 89 |
|
68 |
| - List of fields to be included in the Completion Suggest statistics. |
| 90 | +[[index-stats-api-example]] |
| 91 | +==== {api-examples-title} |
69 | 92 |
|
70 |
| -`fielddata_fields`:: |
71 | 93 |
|
72 |
| - List of fields to be included in the Fielddata statistics. |
| 94 | +[[index-stats-api-multiple-ex]] |
| 95 | +===== Get statistics for multiple indices |
73 | 96 |
|
| 97 | +[source,js] |
| 98 | +-------------------------------------------------- |
| 99 | +GET /index1,index2/_stats |
| 100 | +-------------------------------------------------- |
| 101 | +// CONSOLE |
| 102 | +// TEST[s/^/PUT index1\nPUT index2\n/] |
74 | 103 |
|
75 |
| -Here are some samples: |
| 104 | + |
| 105 | +[[index-stats-api-all-ex]] |
| 106 | +===== Get statistics for all indices |
| 107 | + |
| 108 | +[source,js] |
| 109 | +-------------------------------------------------- |
| 110 | +GET /_stats |
| 111 | +-------------------------------------------------- |
| 112 | +// CONSOLE |
| 113 | +// TEST[setup:twitter] |
| 114 | + |
| 115 | + |
| 116 | +[[index-stats-api-specific-stats-ex]] |
| 117 | +===== Get specific statistics |
| 118 | + |
| 119 | +The following request returns |
| 120 | +only the `merge` and `refresh` statistics |
| 121 | +for all indices. |
76 | 122 |
|
77 | 123 | [source,js]
|
78 | 124 | --------------------------------------------------
|
79 |
| -# Get back stats for merge and refresh only for all indices |
80 | 125 | 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 | 126 | --------------------------------------------------
|
86 | 127 | // CONSOLE
|
87 |
| -// TEST[s/^/PUT my_index\n/] |
| 128 | +// TEST[setup:twitter] |
| 129 | + |
88 | 130 |
|
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. |
| 131 | +[[index-stats-api-specific-groups-ex]] |
| 132 | +===== Get statistics for specific search groups |
92 | 133 |
|
93 |
| -In order to get back shard level stats, set the `level` parameter to `shards`. |
| 134 | +The following request returns |
| 135 | +only search statistics |
| 136 | +for the `group1` and `group2` search groups. |
94 | 137 |
|
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. |
| 138 | +[source,js] |
| 139 | +-------------------------------------------------- |
| 140 | +GET /_stats/search?groups=group1,group2 |
| 141 | +-------------------------------------------------- |
| 142 | +// CONSOLE |
| 143 | +// TEST[setup:twitter] |
0 commit comments