get-data-stream.asciidoc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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. (Required, string)
  77. Name of the data stream to retrieve.
  78. Wildcard (`*`) expressions are supported.
  79. [role="child_attributes"]
  80. [[get-data-stream-api-response-body]]
  81. ==== {api-response-body-title}
  82. `data_streams`::
  83. (array of objects)
  84. Contains information about retrieved data streams.
  85. +
  86. .Properties of objects in `data_streams`
  87. [%collapsible%open]
  88. ====
  89. `name`::
  90. (string)
  91. Name of the data stream.
  92. `timestamp_field`::
  93. (object)
  94. Contains information about the data stream's `@timestamp` field.
  95. +
  96. .Properties of `timestamp_field`
  97. [%collapsible%open]
  98. =====
  99. `name`::
  100. (string)
  101. Name of the data stream's timestamp field, which must be `@timestamp`. The
  102. `@timestamp` field must be included in every document indexed to the data
  103. stream.
  104. =====
  105. `indices`::
  106. (array of objects)
  107. Array of objects containing information about the data stream's backing
  108. indices.
  109. +
  110. The last item in this array contains information about the stream's current
  111. <<data-stream-write-index,write index>>.
  112. +
  113. .Properties of `indices` objects
  114. [%collapsible%open]
  115. =====
  116. `index_name`::
  117. (string)
  118. Name of the backing index. For naming conventions, see
  119. <<data-streams-generation>>.
  120. `index_uuid`::
  121. (string)
  122. Universally unique identifier (UUID) for the index.
  123. =====
  124. `generation`::
  125. (integer)
  126. Current <<data-streams-generation,generation>> for the data stream. This number
  127. acts as a cumulative count of the stream's backing indices, including
  128. deleted indices.
  129. `status`::
  130. (string)
  131. <<cluster-health,Health status>> of the data stream.
  132. +
  133. This health status is based on the state of the primary and replica shards of
  134. the stream's backing indices.
  135. +
  136. .Values for `status`
  137. [%collapsible%open]
  138. =====
  139. `green`:::
  140. All shards are assigned.
  141. `yellow`:::
  142. All primary shards are assigned, but one or more replica shards are
  143. unassigned.
  144. `red`:::
  145. One or more primary shards are unassigned, so some data is unavailable.
  146. =====
  147. `template`::
  148. (string)
  149. Name of the index template used to create the data stream's backing indices.
  150. +
  151. The template's index pattern must match the name of this data stream. See
  152. <<create-a-data-stream-template>>.
  153. `ilm_policy`::
  154. (string)
  155. Name of the current {ilm-init} lifecycle policy in the stream's matching index
  156. template. This lifecycle policy is set in the `index.lifecycle.name` setting.
  157. +
  158. If the template does not include a lifecycle policy, this property is not
  159. included in the response.
  160. +
  161. NOTE: A data stream's backing indices may be assigned different lifecycle
  162. policies. To retrieve the lifecycle policy for individual backing indices,
  163. use the <<indices-get-settings,get index settings API>>.
  164. ====
  165. [[get-data-stream-api-example]]
  166. ==== {api-examples-title}
  167. [source,console]
  168. ----
  169. GET _data_stream/my-data-stream*
  170. ----
  171. The API returns the following response:
  172. [source,console-result]
  173. ----
  174. {
  175. "data_streams": [
  176. {
  177. "name": "my-data-stream",
  178. "timestamp_field": {
  179. "name": "@timestamp"
  180. },
  181. "indices": [
  182. {
  183. "index_name": ".ds-my-data-stream-000001",
  184. "index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"
  185. },
  186. {
  187. "index_name": ".ds-my-data-stream-000002",
  188. "index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"
  189. }
  190. ],
  191. "generation": 2,
  192. "status": "GREEN",
  193. "template": "my-index-template",
  194. "ilm_policy": "my-lifecycle-policy"
  195. },
  196. {
  197. "name": "my-data-stream_two",
  198. "timestamp_field": {
  199. "name": "@timestamp"
  200. },
  201. "indices": [
  202. {
  203. "index_name": ".ds-my-data-stream_two-000001",
  204. "index_uuid": "3liBu2SYS5axasRt6fUIpA"
  205. }
  206. ],
  207. "generation": 1,
  208. "status": "YELLOW",
  209. "template": "my-index-template",
  210. "ilm_policy": "my-lifecycle-policy"
  211. }
  212. ]
  213. }
  214. ----
  215. // TESTRESPONSE[s/"index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"/"index_uuid": $body.data_streams.0.indices.0.index_uuid/]
  216. // TESTRESPONSE[s/"index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"/"index_uuid": $body.data_streams.0.indices.1.index_uuid/]
  217. // TESTRESPONSE[s/"index_uuid": "3liBu2SYS5axasRt6fUIpA"/"index_uuid": $body.data_streams.1.indices.0.index_uuid/]
  218. // TESTRESPONSE[s/"status": "GREEN"/"status": "YELLOW"/]