data-stream-stats.asciidoc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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-request]]
  47. ==== {api-request-title}
  48. `GET /_data_stream/<data-stream>/_stats`
  49. [[data-stream-stats-api-path-params]]
  50. ==== {api-path-parms-title}
  51. `<data-stream>`::
  52. (Optional, string)
  53. Comma-separated list of data streams used to limit the request. Wildcard
  54. expressions (`*`) are supported.
  55. +
  56. To target all data streams in a cluster, omit this parameter or use `*`.
  57. [[data-stream-stats-api-query-params]]
  58. ==== {api-query-parms-title}
  59. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=ds-expand-wildcards]
  60. +
  61. Defaults to `open`.
  62. `human`::
  63. (Optional, Boolean)
  64. If `true`, the response includes statistics in human-readable <<byte-units,byte
  65. values>>. Defaults to `false`.
  66. [role="child_attributes"]
  67. [[data-stream-stats-api-response-body]]
  68. ==== {api-response-body-title}
  69. `_shards`::
  70. (object)
  71. Contains information about shards that attempted to execute the request.
  72. +
  73. .Properties of `_shards`
  74. [%collapsible%open]
  75. ====
  76. `total`::
  77. (integer)
  78. Total number of shards that attempted to execute the request.
  79. `successful`::
  80. (integer)
  81. Number of shards that successfully executed the request.
  82. `failed`::
  83. (integer)
  84. Number of shards that failed to execute the request.
  85. ====
  86. `data_stream_count`::
  87. (integer)
  88. Total number of selected data streams.
  89. `backing_indices`::
  90. (integer)
  91. Total number of backing indices for the selected data streams.
  92. `total_store_sizes`::
  93. (<<byte-units,byte value>>)
  94. Total size of all shards for the selected data streams.
  95. This property is included only if the `human` query parameter is `true`.
  96. `total_store_size_bytes`::
  97. (integer)
  98. Total size, in bytes, of all shards for the selected data streams.
  99. `data_streams`::
  100. (array of objects)
  101. Contains statistics for the selected data streams.
  102. +
  103. .Properties of objects in `data_streams`
  104. [%collapsible%open]
  105. ====
  106. `data_stream`::
  107. (string)
  108. Name of the data stream.
  109. `backing_indices`::
  110. (integer)
  111. Current number of backing indices for the data stream.
  112. `store_size`::
  113. (<<byte-units,byte value>>)
  114. Total size of all shards for the data stream's backing indices.
  115. This parameter is only returned if the `human` query parameter is `true`.
  116. `store_size_bytes`::
  117. (integer)
  118. Total size, in bytes, of all shards for the data stream's backing indices.
  119. `maximum_timestamp`::
  120. (integer)
  121. The data stream's highest `@timestamp` value, converted to milliseconds since
  122. the {wikipedia}/Unix_time[Unix epoch].
  123. +
  124. [NOTE]
  125. =====
  126. This timestamp is provided as a best effort. The data stream may contain
  127. `@timestamp` values higher than this if one or more of the following conditions
  128. are met:
  129. * The stream contains <<indices-open-close,closed>> backing indices.
  130. * Backing indices with a <<data-streams-generation,lower generation>> contain
  131. higher `@timestamp` values.
  132. =====
  133. ====
  134. [[data-stream-stats-api-example]]
  135. ==== {api-examples-title}
  136. [source,console]
  137. ----
  138. GET /_data_stream/my-data-stream*/_stats?human=true
  139. ----
  140. The API returns the following response.
  141. [source,console-result]
  142. ----
  143. {
  144. "_shards": {
  145. "total": 10,
  146. "successful": 5,
  147. "failed": 0
  148. },
  149. "data_stream_count": 2,
  150. "backing_indices": 5,
  151. "total_store_size": "7kb",
  152. "total_store_size_bytes": 7268,
  153. "data_streams": [
  154. {
  155. "data_stream": "my-data-stream",
  156. "backing_indices": 3,
  157. "store_size": "3.7kb",
  158. "store_size_bytes": 3772,
  159. "maximum_timestamp": 1607512028000
  160. },
  161. {
  162. "data_stream": "my-data-stream-two",
  163. "backing_indices": 2,
  164. "store_size": "3.4kb",
  165. "store_size_bytes": 3496,
  166. "maximum_timestamp": 1607425567000
  167. }
  168. ]
  169. }
  170. ----
  171. // TESTRESPONSE[s/"total_store_size": "7kb"/"total_store_size": $body.total_store_size/]
  172. // TESTRESPONSE[s/"total_store_size_bytes": 7268/"total_store_size_bytes": $body.total_store_size_bytes/]
  173. // TESTRESPONSE[s/"store_size": "3.7kb"/"store_size": $body.data_streams.0.store_size/]
  174. // TESTRESPONSE[s/"store_size_bytes": 3772/"store_size_bytes": $body.data_streams.0.store_size_bytes/]
  175. // TESTRESPONSE[s/"store_size": "3.4kb"/"store_size": $body.data_streams.1.store_size/]
  176. // TESTRESPONSE[s/"store_size_bytes": 3496/"store_size_bytes": $body.data_streams.1.store_size_bytes/]