stats.asciidoc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. [[indices-stats]]
  2. === Index stats API
  3. ++++
  4. <titleabbrev>Index stats</titleabbrev>
  5. ++++
  6. Returns statistics for one or more indices. For data streams, the API retrieves
  7. statistics for the stream's backing indices.
  8. [source,console]
  9. ----
  10. GET /my-index-000001/_stats
  11. ----
  12. // TEST[setup:my_index]
  13. [[index-stats-api-request]]
  14. ==== {api-request-title}
  15. `GET /<target>/_stats/<index-metric>`
  16. `GET /<target>/_stats`
  17. `GET /_stats`
  18. [[index-stats-api-desc]]
  19. ==== {api-description-title}
  20. Use the index stats API to get high-level aggregation and statistics for one or
  21. more data streams and indices.
  22. By default,
  23. the returned statistics are index-level
  24. with `primaries` and `total` aggregations.
  25. `primaries` are the values for only the primary shards.
  26. `total` are the accumulated values for both primary and replica shards.
  27. To get shard-level statistics,
  28. set the `level` parameter to `shards`.
  29. [NOTE]
  30. ====
  31. When moving to another node,
  32. the shard-level statistics for a shard are cleared.
  33. Although the shard
  34. is no longer part of the node,
  35. that node retains any node-level statistics
  36. to which the shard contributed.
  37. ====
  38. [[index-stats-api-path-params]]
  39. ==== {api-path-parms-title}
  40. `<target>`::
  41. (Optional, string)
  42. Comma-separated list of data streams, indices, and index aliases used to limit
  43. the request. Wildcard expressions (`*`) are supported.
  44. +
  45. To target all data streams and indices in a cluster, omit this parameter or use
  46. `_all` or `*`.
  47. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-metric]
  48. [[index-stats-api-query-params]]
  49. ==== {api-query-parms-title}
  50. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  51. +
  52. Defaults to `open`.
  53. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=fields]
  54. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=completion-fields]
  55. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=fielddata-fields]
  56. `forbid_closed_indices`::
  57. (Optional, boolean)
  58. If `true`, statistics are *not* collected from closed indices.
  59. Defaults to `true`.
  60. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=groups]
  61. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=level]
  62. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes]
  63. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments]
  64. [[index-stats-api-example]]
  65. ==== {api-examples-title}
  66. [[index-stats-api-multiple-ex]]
  67. ===== Get statistics for multiple data streams and indices
  68. [source,console]
  69. --------------------------------------------------
  70. GET /index1,index2/_stats
  71. --------------------------------------------------
  72. // TEST[s/^/PUT index1\nPUT index2\n/]
  73. [[index-stats-api-all-ex]]
  74. ===== Get statistics for all data streams and indices in a cluster
  75. [source,console]
  76. --------------------------------------------------
  77. GET /_stats
  78. --------------------------------------------------
  79. // TEST[setup:my_index]
  80. [[index-stats-api-specific-stats-ex]]
  81. ===== Get specific statistics
  82. The following request returns
  83. only the `merge` and `refresh` statistics
  84. for all indices.
  85. [source,console]
  86. --------------------------------------------------
  87. GET /_stats/merge,refresh
  88. --------------------------------------------------
  89. // TEST[setup:my_index]
  90. [[index-stats-api-specific-groups-ex]]
  91. ===== Get statistics for specific search groups
  92. The following request returns
  93. only search statistics
  94. for the `group1` and `group2` search groups.
  95. [source,console]
  96. --------------------------------------------------
  97. GET /_stats/search?groups=group1,group2
  98. --------------------------------------------------
  99. // TEST[setup:my_index]