stats.asciidoc 3.8 KB

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