data-stream-stats.asciidoc 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. [role="xpack"]
  2. [[data-stream-stats-api]]
  3. === Data stream stats API
  4. ++++
  5. <titleabbrev>Data stream stats</titleabbrev>
  6. ++++
  7. Retrieves statistics for one or more <<data-streams,data streams>>.
  8. ////
  9. [source,console]
  10. ----
  11. PUT /_index_template/template
  12. {
  13. "index_patterns": ["my-data-stream*"],
  14. "data_stream": { }
  15. }
  16. PUT /my-data-stream/_bulk?refresh
  17. {"create":{ }}
  18. { "@timestamp": "2020-12-08T11:04:05.000Z" }
  19. {"create":{ }}
  20. { "@timestamp": "2020-12-08T11:06:07.000Z" }
  21. {"create":{ }}
  22. { "@timestamp": "2020-12-09T11:07:08.000Z" }
  23. POST /my-data-stream/_rollover/
  24. POST /my-data-stream/_rollover/
  25. PUT /my-data-stream-two/_bulk?refresh
  26. {"create":{ }}
  27. { "@timestamp": "2020-12-08T11:04:05.000Z" }
  28. {"create":{ }}
  29. { "@timestamp": "2020-12-08T11:06:07.000Z" }
  30. POST /my-data-stream-two/_rollover/
  31. ----
  32. // TESTSETUP
  33. ////
  34. ////
  35. [source,console]
  36. ----
  37. DELETE /_data_stream/*
  38. DELETE /_index_template/*
  39. ----
  40. // TEARDOWN
  41. ////
  42. [source,console]
  43. ----
  44. GET /_data_stream/my-data-stream/_stats
  45. ----
  46. [[data-stream-stats-api-prereqs]]
  47. ==== {api-prereq-title}
  48. * If the {es} {security-features} are enabled, you must have the
  49. `monitor` or `manage` <<privileges-list-indices,index privilege>>
  50. for the data stream.
  51. [[data-stream-stats-api-request]]
  52. ==== {api-request-title}
  53. `GET /_data_stream/<data-stream>/_stats`
  54. [[data-stream-stats-api-path-params]]
  55. ==== {api-path-parms-title}
  56. `<data-stream>`::
  57. (Optional, string)
  58. Comma-separated list of data streams used to limit the request. Wildcard
  59. expressions (`*`) are supported.
  60. +
  61. To target all data streams in a cluster, omit this parameter or use `*`.
  62. [[data-stream-stats-api-query-params]]
  63. ==== {api-query-parms-title}
  64. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=ds-expand-wildcards]
  65. +
  66. Defaults to `open`.
  67. `human`::
  68. (Optional, Boolean)
  69. If `true`, the response includes statistics in human-readable <<byte-units,byte
  70. values>>. Defaults to `false`.
  71. [role="child_attributes"]
  72. [[data-stream-stats-api-response-body]]
  73. ==== {api-response-body-title}
  74. `_shards`::
  75. (object)
  76. Contains information about shards that attempted to execute the request.
  77. +
  78. .Properties of `_shards`
  79. [%collapsible%open]
  80. ====
  81. `total`::
  82. (integer)
  83. Total number of shards that attempted to execute the request.
  84. `successful`::
  85. (integer)
  86. Number of shards that successfully executed the request.
  87. `failed`::
  88. (integer)
  89. Number of shards that failed to execute the request.
  90. ====
  91. `data_stream_count`::
  92. (integer)
  93. Total number of selected data streams.
  94. `backing_indices`::
  95. (integer)
  96. Total number of backing indices for the selected data streams.
  97. `total_store_sizes`::
  98. (<<byte-units,byte value>>)
  99. Total size of all shards for the selected data streams.
  100. This property is included only if the `human` query parameter is `true`.
  101. `total_store_size_bytes`::
  102. (integer)
  103. Total size, in bytes, of all shards for the selected data streams.
  104. `data_streams`::
  105. (array of objects)
  106. Contains statistics for the selected data streams.
  107. +
  108. .Properties of objects in `data_streams`
  109. [%collapsible%open]
  110. ====
  111. `data_stream`::
  112. (string)
  113. Name of the data stream.
  114. `backing_indices`::
  115. (integer)
  116. Current number of backing indices for the data stream.
  117. `store_size`::
  118. (<<byte-units,byte value>>)
  119. Total size of all shards for the data stream's backing indices.
  120. This parameter is only returned if the `human` query parameter is `true`.
  121. `store_size_bytes`::
  122. (integer)
  123. Total size, in bytes, of all shards for the data stream's backing indices.
  124. `maximum_timestamp`::
  125. (integer)
  126. The data stream's highest `@timestamp` value, converted to milliseconds since
  127. the {wikipedia}/Unix_time[Unix epoch].
  128. +
  129. [NOTE]
  130. =====
  131. This timestamp is provided as a best effort. The data stream may contain
  132. `@timestamp` values higher than this if one or more of the following conditions
  133. are met:
  134. * The stream contains <<indices-open-close,closed>> backing indices.
  135. * Backing indices with a <<data-streams-generation,lower generation>> contain
  136. higher `@timestamp` values.
  137. =====
  138. ====
  139. [[data-stream-stats-api-example]]
  140. ==== {api-examples-title}
  141. [source,console]
  142. ----
  143. GET /_data_stream/my-data-stream*/_stats?human=true
  144. ----
  145. The API returns the following response.
  146. [source,console-result]
  147. ----
  148. {
  149. "_shards": {
  150. "total": 10,
  151. "successful": 5,
  152. "failed": 0
  153. },
  154. "data_stream_count": 2,
  155. "backing_indices": 5,
  156. "total_store_size": "7kb",
  157. "total_store_size_bytes": 7268,
  158. "data_streams": [
  159. {
  160. "data_stream": "my-data-stream",
  161. "backing_indices": 3,
  162. "store_size": "3.7kb",
  163. "store_size_bytes": 3772,
  164. "maximum_timestamp": 1607512028000
  165. },
  166. {
  167. "data_stream": "my-data-stream-two",
  168. "backing_indices": 2,
  169. "store_size": "3.4kb",
  170. "store_size_bytes": 3496,
  171. "maximum_timestamp": 1607425567000
  172. }
  173. ]
  174. }
  175. ----
  176. // TESTRESPONSE[s/"total_store_size": "7kb"/"total_store_size": $body.total_store_size/]
  177. // TESTRESPONSE[s/"total_store_size_bytes": 7268/"total_store_size_bytes": $body.total_store_size_bytes/]
  178. // TESTRESPONSE[s/"store_size": "3.7kb"/"store_size": $body.data_streams.0.store_size/]
  179. // TESTRESPONSE[s/"store_size_bytes": 3772/"store_size_bytes": $body.data_streams.0.store_size_bytes/]
  180. // TESTRESPONSE[s/"store_size": "3.4kb"/"store_size": $body.data_streams.1.store_size/]
  181. // TESTRESPONSE[s/"store_size_bytes": 3496/"store_size_bytes": $body.data_streams.1.store_size_bytes/]