data-stream-stats.asciidoc 4.9 KB

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