get-data-stream.asciidoc 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. [role="xpack"]
  2. [[indices-get-data-stream]]
  3. === Get data stream API
  4. ++++
  5. <titleabbrev>Get data stream</titleabbrev>
  6. ++++
  7. Retrieves information about one or more <<data-streams,data streams>>.
  8. See <<get-info-about-a-data-stream>>.
  9. ////
  10. [source,console]
  11. ----
  12. PUT /_ilm/policy/my-lifecycle-policy
  13. {
  14. "policy": {
  15. "phases": {
  16. "hot": {
  17. "actions": {
  18. "rollover": {
  19. "max_size": "25GB"
  20. }
  21. }
  22. },
  23. "delete": {
  24. "min_age": "30d",
  25. "actions": {
  26. "delete": {}
  27. }
  28. }
  29. }
  30. }
  31. }
  32. PUT /_index_template/my-index-template
  33. {
  34. "index_patterns": [ "my-data-stream*" ],
  35. "data_stream": {
  36. "timestamp_field": "@timestamp"
  37. },
  38. "template": {
  39. "mappings": {
  40. "properties": {
  41. "@timestamp": {
  42. "type": "date"
  43. }
  44. }
  45. },
  46. "settings": {
  47. "index.lifecycle.name": "my-lifecycle-policy"
  48. }
  49. }
  50. }
  51. PUT /_data_stream/my-data-stream
  52. POST /my-data-stream/_rollover
  53. PUT /_data_stream/my-data-stream_two
  54. ----
  55. // TESTSETUP
  56. ////
  57. ////
  58. [source,console]
  59. ----
  60. DELETE /_data_stream/*
  61. DELETE /_index_template/*
  62. DELETE /_ilm/policy/my-lifecycle-policy
  63. ----
  64. // TEARDOWN
  65. ////
  66. [source,console]
  67. ----
  68. GET /_data_stream/my-data-stream
  69. ----
  70. [[get-data-stream-api-request]]
  71. ==== {api-request-title}
  72. `GET /_data_stream/<data-stream>`
  73. [[get-data-stream-api-path-params]]
  74. ==== {api-path-parms-title}
  75. `<data-stream>`::
  76. (Optional, string)
  77. Comma-separated list of data stream names used to limit the request. Wildcard
  78. (`*`) expressions are supported. If omitted, all data streams will be
  79. returned.
  80. [role="child_attributes"]
  81. [[get-data-stream-api-response-body]]
  82. ==== {api-response-body-title}
  83. `data_streams`::
  84. (array of objects)
  85. Contains information about retrieved data streams.
  86. +
  87. .Properties of objects in `data_streams`
  88. [%collapsible%open]
  89. ====
  90. `name`::
  91. (string)
  92. Name of the data stream.
  93. `timestamp_field`::
  94. (object)
  95. Contains information about the data stream's `@timestamp` field.
  96. +
  97. .Properties of `timestamp_field`
  98. [%collapsible%open]
  99. =====
  100. `name`::
  101. (string)
  102. Name of the data stream's timestamp field, which must be `@timestamp`. The
  103. `@timestamp` field must be included in every document indexed to the data
  104. stream.
  105. =====
  106. `indices`::
  107. (array of objects)
  108. Array of objects containing information about the data stream's backing
  109. indices.
  110. +
  111. The last item in this array contains information about the stream's current
  112. <<data-stream-write-index,write index>>.
  113. +
  114. .Properties of `indices` objects
  115. [%collapsible%open]
  116. =====
  117. `index_name`::
  118. (string)
  119. Name of the backing index. For naming conventions, see
  120. <<data-streams-generation>>.
  121. `index_uuid`::
  122. (string)
  123. Universally unique identifier (UUID) for the index.
  124. =====
  125. `generation`::
  126. (integer)
  127. Current <<data-streams-generation,generation>> for the data stream. This number
  128. acts as a cumulative count of the stream's backing indices, including
  129. deleted indices.
  130. `status`::
  131. (string)
  132. <<cluster-health,Health status>> of the data stream.
  133. +
  134. This health status is based on the state of the primary and replica shards of
  135. the stream's backing indices.
  136. +
  137. .Values for `status`
  138. [%collapsible%open]
  139. =====
  140. `green`:::
  141. All shards are assigned.
  142. `yellow`:::
  143. All primary shards are assigned, but one or more replica shards are
  144. unassigned.
  145. `red`:::
  146. One or more primary shards are unassigned, so some data is unavailable.
  147. =====
  148. `template`::
  149. (string)
  150. Name of the index template used to create the data stream's backing indices.
  151. +
  152. The template's index pattern must match the name of this data stream. See
  153. <<create-a-data-stream-template>>.
  154. `ilm_policy`::
  155. (string)
  156. Name of the current {ilm-init} lifecycle policy in the stream's matching index
  157. template. This lifecycle policy is set in the `index.lifecycle.name` setting.
  158. +
  159. If the template does not include a lifecycle policy, this property is not
  160. included in the response.
  161. +
  162. NOTE: A data stream's backing indices may be assigned different lifecycle
  163. policies. To retrieve the lifecycle policy for individual backing indices,
  164. use the <<indices-get-settings,get index settings API>>.
  165. ====
  166. [[get-data-stream-api-example]]
  167. ==== {api-examples-title}
  168. [source,console]
  169. ----
  170. GET _data_stream/my-data-stream*
  171. ----
  172. The API returns the following response:
  173. [source,console-result]
  174. ----
  175. {
  176. "data_streams": [
  177. {
  178. "name": "my-data-stream",
  179. "timestamp_field": {
  180. "name": "@timestamp"
  181. },
  182. "indices": [
  183. {
  184. "index_name": ".ds-my-data-stream-000001",
  185. "index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"
  186. },
  187. {
  188. "index_name": ".ds-my-data-stream-000002",
  189. "index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"
  190. }
  191. ],
  192. "generation": 2,
  193. "status": "GREEN",
  194. "template": "my-index-template",
  195. "ilm_policy": "my-lifecycle-policy"
  196. },
  197. {
  198. "name": "my-data-stream_two",
  199. "timestamp_field": {
  200. "name": "@timestamp"
  201. },
  202. "indices": [
  203. {
  204. "index_name": ".ds-my-data-stream_two-000001",
  205. "index_uuid": "3liBu2SYS5axasRt6fUIpA"
  206. }
  207. ],
  208. "generation": 1,
  209. "status": "YELLOW",
  210. "template": "my-index-template",
  211. "ilm_policy": "my-lifecycle-policy"
  212. }
  213. ]
  214. }
  215. ----
  216. // TESTRESPONSE[s/"index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"/"index_uuid": $body.data_streams.0.indices.0.index_uuid/]
  217. // TESTRESPONSE[s/"index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"/"index_uuid": $body.data_streams.0.indices.1.index_uuid/]
  218. // TESTRESPONSE[s/"index_uuid": "3liBu2SYS5axasRt6fUIpA"/"index_uuid": $body.data_streams.1.indices.0.index_uuid/]
  219. // TESTRESPONSE[s/"status": "GREEN"/"status": "YELLOW"/]