data-stream-stats.asciidoc 4.9 KB

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