[DOCS] Reformat index stats API docs (#46322)

This commit is contained in:
James Rodewig 2019-09-05 15:03:33 -04:00
parent 758680c549
commit 327da31db4
3 changed files with 266 additions and 100 deletions

View File

@ -113,25 +113,15 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=node-id]
[[cluster-nodes-stats-api-query-params]] [[cluster-nodes-stats-api-query-params]]
==== {api-query-parms-title} ==== {api-query-parms-title}
`completion_fields`:: include::{docdir}/rest-api/common-parms.asciidoc[tag=completion-fields]
(Optional, string) A comma-separated list of fields for `fielddata` and
`suggest` index metric (supports wildcards).
`fielddata_fields`:: include::{docdir}/rest-api/common-parms.asciidoc[tag=fielddata-fields]
(Optional, string) A comma-separated list of fields for `fielddata` index
metric (supports wildcards).
`fields`:: include::{docdir}/rest-api/common-parms.asciidoc[tag=fields]
(Optional, string) A comma-separated list of fields for `fielddata` and
`completion` index metric (supports wildcards).
`groups`:: include::{docdir}/rest-api/common-parms.asciidoc[tag=groups]
(Optional, string) A comma-separated list of search groups for `search`
index metric.
`level`:: include::{docdir}/rest-api/common-parms.asciidoc[tag=level]
(Optional, string) Returns indices stats aggregated at index, node or shard
level. Supported options: `indices`, `node`, `shards`.
`types`:: `types`::
(Optional, string) A comma-separated list of document types for the (Optional, string) A comma-separated list of document types for the
@ -139,10 +129,7 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=node-id]
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms] include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
`include_segment_file_sizes`:: include::{docdir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes]
(Optional, boolean) If `true`, the call reports the aggregated disk usage of
each one of the Lucene index files (only applies if segment stats are
requested). Defaults to `false`.
[[cluster-nodes-stats-api-response-body]] [[cluster-nodes-stats-api-response-body]]

View File

@ -1,98 +1,138 @@
[[indices-stats]] [[indices-stats]]
=== Indices Stats === Index stats API
++++
<titleabbrev>Index stats</titleabbrev>
++++
Indices level stats provide statistics on different operations happening Returns statistics for an index.
on an index. The API provides statistics on the index level scope
(though most stats can also be retrieved using node level scope).
The following returns high level aggregation and index level stats for [source,console]
all indices: ----
GET /twitter/_stats
----
// TEST[setup:twitter]
[source,js]
--------------------------------------------------
GET /_stats
--------------------------------------------------
// CONSOLE
Specific index stats can be retrieved using: [[index-stats-api-request]]
==== {api-request-title}
[source,js] `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 GET /index1,index2/_stats
-------------------------------------------------- --------------------------------------------------
// CONSOLE
// TEST[s/^/PUT index1\nPUT index2\n/] // TEST[s/^/PUT index1\nPUT index2\n/]
By default, all stats are returned, returning only specific stats can be
specified as well in the URI. Those stats can be any of:
[horizontal] [[index-stats-api-all-ex]]
`docs`:: The number of docs / deleted docs (docs not yet merged out). ===== Get statistics for all indices
Note, affected by refreshing the index.
`store`:: The size of the index. [source,console]
--------------------------------------------------
`indexing`:: Indexing statistics, can be combined with a comma GET /_stats
separated list of `types` to provide document type level stats. --------------------------------------------------
// TEST[setup:twitter]
`get`:: Get statistics, including missing stats.
`search`:: Search statistics including suggest statistics. [[index-stats-api-specific-stats-ex]]
You can include statistics for custom groups by adding ===== Get specific statistics
an extra `groups` parameter (search operations can be associated with one or more
groups). The `groups` parameter accepts a comma separated list of group names. The following request returns
Use `_all` to return statistics for all groups. only the `merge` and `refresh` statistics
for all indices.
`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.
[source,console]
`completion`:: Completion suggest statistics.
`fielddata`:: Fielddata statistics.
`flush`:: Flush statistics.
`merge`:: Merge statistics.
`request_cache`:: <<shard-request-cache,Shard request cache>> statistics.
`refresh`:: Refresh statistics.
`warmer`:: Warmer statistics.
`translog`:: Translog statistics.
Some statistics allow per field granularity which accepts a list
comma-separated list of included fields. By default all fields are included:
[horizontal]
`fields`::
List of fields to be included in the statistics. This is used as the
default list unless a more specific field list is provided (see below).
`completion_fields`::
List of fields to be included in the Completion Suggest statistics.
`fielddata_fields`::
List of fields to be included in the Fielddata statistics.
Here are some samples:
[source,js]
-------------------------------------------------- --------------------------------------------------
# Get back stats for merge and refresh only for all indices
GET /_stats/merge,refresh GET /_stats/merge,refresh
# Get back stats for type1 and type2 documents for the my_index index --------------------------------------------------
GET /my_index/_stats/indexing?types=type1,type2 // TEST[setup:twitter]
# Get back just search stats for group1 and group2
[[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 GET /_stats/search?groups=group1,group2
-------------------------------------------------- --------------------------------------------------
// CONSOLE // TEST[setup:twitter]
// TEST[s/^/PUT my_index\n/]
The stats returned are aggregated on the index level, with
`primaries` and `total` aggregations, where `primaries` are the values for only the
primary shards, and `total` are the accumulated values for both primary and replica shards.
In order to get back shard level stats, set the `level` parameter to `shards`.
Note, as shards move around the cluster, their stats will be cleared as
they are created on other nodes. On the other hand, even though a shard
"left" a node, that node will still retain the stats that shard
contributed to.

View File

@ -52,6 +52,13 @@ the transaction log so that Elasticsearch is able to replay
changes on the next start. changes on the next start.
end::committed[] end::committed[]
tag::completion-fields[]
`completion_fields`::
(Optional, string)
Comma-separated list or wildcard expressions of fields
to include in `fielddata` and `suggest` statistics.
end::completion-fields[]
tag::default_operator[] tag::default_operator[]
`default_operator`:: `default_operator`::
(Optional, string) The default operator for query string query: AND or OR. (Optional, string) The default operator for query string query: AND or OR.
@ -105,6 +112,35 @@ If specified,
the index alias only applies to documents returned by the filter. the index alias only applies to documents returned by the filter.
end::index-alias-filter[] end::index-alias-filter[]
tag::fielddata-fields[]
`fielddata_fields`::
(Optional, string)
Comma-separated list or wildcard expressions of fields
to include in `fielddata` statistics.
end::fielddata-fields[]
tag::fields[]
`fields`::
+
--
(Optional, string)
Comma-separated list or wildcard expressions of fields
to include in the statistics.
Used as the default list
unless a specific field list is provided
in the `completion_fields` or `fielddata_fields` parameters.
--
end::fields[]
tag::index-alias-filter[]
<<query-dsl-bool-query, Filter query>>
used to limit the index alias.
+
If specified,
the index alias only applies to documents returned by the filter.
end::index-alias-filter[]
tag::flat-settings[] tag::flat-settings[]
`flat_settings`:: `flat_settings`::
(Optional, boolean) If `true`, returns settings in flat format. Defaults to (Optional, boolean) If `true`, returns settings in flat format. Defaults to
@ -128,6 +164,13 @@ tag::from[]
(Optional, integer) Starting document offset. Defaults to `0`. (Optional, integer) Starting document offset. Defaults to `0`.
end::from[] end::from[]
tag::groups[]
`groups`::
(Optional, string)
Comma-separated list of search groups
to include in the `search` statistics.
end::groups[]
tag::cat-h[] tag::cat-h[]
`h`:: `h`::
(Optional, string) Comma-separated list of column names to display. (Optional, string) Comma-separated list of column names to display.
@ -181,6 +224,14 @@ tag::index-ignore-unavailable[]
response. Defaults to `false`. response. Defaults to `false`.
end::index-ignore-unavailable[] end::index-ignore-unavailable[]
tag::include-segment-file-sizes[]
`include_segment_file_sizes`::
(Optional, boolean)
If `true`, the call reports the aggregated disk usage of
each one of the Lucene index files (only applies if segment stats are
requested). Defaults to `false`.
end::include-segment-file-sizes[]
tag::include-unloaded-segments[] tag::include-unloaded-segments[]
`include_unloaded_segments`:: `include_unloaded_segments`::
(Optional, boolean) If `true`, the response includes information from segments (Optional, boolean) If `true`, the response includes information from segments
@ -193,6 +244,78 @@ tag::index[]
used to limit the request. used to limit the request.
end::index[] end::index[]
tag::index-metric[]
`<index-metric>`::
+
--
(Optional, string)
Comma-separated list of metrics used to limit the request.
Supported metrics are:
`_all`::
Return all statistics.
`completion`::
<<completion-suggester,Completion suggester>> statistics.
`docs`::
Number of documents and deleted docs, which have not yet merged out.
<<indices-refresh,Index refreshes>> can affect this statistic.
`fielddata`::
<<fielddata,Fielddata>> statistics.
`flush`::
<<indices-flush,Flush>> statistics.
`get`::
Get statistics,
including missing stats.
`indexing`::
<<docs-index_,Indexing>> statistics.
`merge`::
<<index-modules-merge,Merge>> statistics.
`query_cache`::
<<query-cache,Query cache>> statistics.
`refresh`::
<<indices-refresh,Refresh>> statistics.
`request_cache`::
<<shard-request-cache,Shard request cache>> statistics.
`search`::
Search statistics including suggest statistics.
You can include statistics for custom groups
by adding an extra `groups` parameter
(search operations can be associated with one or more groups).
The `groups` parameter accepts a comma separated list of group names.
Use `_all` to return statistics for all groups.
`segments`::
Memory use of all open segments.
+
If the `include_segment_file_sizes` parameter is `true`,
this metric includes the aggregated disk usage
of each Lucene index file.
`store`::
Size of the index in <<byte-units, byte units>>.
`suggest`::
<<search-suggesters,Suggester>> statistics.
`translog`::
<<index-modules-translog,Translog>> statistics.
`warmer`::
<<indices-warmers,Warmer>> statistics.
--
end::index-metric[]
tag::index-template[] tag::index-template[]
`<index-template>`:: `<index-template>`::
(Required, string) (Required, string)
@ -206,6 +329,22 @@ tag::lenient[]
providing text to a numeric field) will be ignored. Defaults to `false`. providing text to a numeric field) will be ignored. Defaults to `false`.
end::lenient[] end::lenient[]
tag::level[]
`level`::
+
--
(Optional, string)
Indicates whether statistics are aggregated
at the cluster, index, or shard level.
Valid values are:
* `cluster`
* `indices`
* `shards`
--
end::level[]
tag::local[] tag::local[]
`local`:: `local`::
(Optional, boolean) If `true`, the request retrieves information from the local (Optional, boolean) If `true`, the request retrieves information from the local