get-data-stream.asciidoc 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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-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_primary_shard_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. "template": {
  37. "settings": {
  38. "index.lifecycle.name": "my-lifecycle-policy"
  39. }
  40. },
  41. "_meta": {
  42. "my-meta-field": "foo"
  43. }
  44. }
  45. PUT /_data_stream/my-data-stream
  46. POST /my-data-stream/_rollover
  47. PUT /_data_stream/my-data-stream-two
  48. ----
  49. // TESTSETUP
  50. ////
  51. ////
  52. [source,console]
  53. ----
  54. DELETE /_data_stream/*
  55. DELETE /_index_template/*
  56. DELETE /_ilm/policy/my-lifecycle-policy
  57. ----
  58. // TEARDOWN
  59. ////
  60. [source,console]
  61. ----
  62. GET /_data_stream/my-data-stream
  63. ----
  64. [[get-data-stream-api-request]]
  65. ==== {api-request-title}
  66. `GET /_data_stream/<data-stream>`
  67. [[get-data-stream-api-prereqs]]
  68. ==== {api-prereq-title}
  69. * If the {es} {security-features} are enabled, you must have the
  70. `view_index_metadata` or `manage` <<privileges-list-indices,index privilege>>
  71. for the data stream.
  72. [[get-data-stream-api-path-params]]
  73. ==== {api-path-parms-title}
  74. `<data-stream>`::
  75. (Optional, string)
  76. Comma-separated list of data stream names used to limit the request. Wildcard
  77. (`*`) expressions are supported. If omitted, all data streams will be
  78. returned.
  79. [role="child_attributes"]
  80. [[get-data-stream-api-query-parms]]
  81. ==== {api-query-parms-title}
  82. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=ds-expand-wildcards]
  83. +
  84. Defaults to `open`.
  85. [role="child_attributes"]
  86. [[get-data-stream-api-response-body]]
  87. ==== {api-response-body-title}
  88. `data_streams`::
  89. (array of objects)
  90. Contains information about retrieved data streams.
  91. +
  92. .Properties of objects in `data_streams`
  93. [%collapsible%open]
  94. ====
  95. `name`::
  96. (string)
  97. Name of the data stream.
  98. `timestamp_field`::
  99. (object)
  100. Contains information about the data stream's `@timestamp` field.
  101. +
  102. .Properties of `timestamp_field`
  103. [%collapsible%open]
  104. =====
  105. `name`::
  106. (string)
  107. Name of the data stream's timestamp field, which must be `@timestamp`. The
  108. `@timestamp` field must be included in every document indexed to the data
  109. stream.
  110. =====
  111. `indices`::
  112. (array of objects)
  113. Array of objects containing information about the data stream's backing
  114. indices.
  115. +
  116. The last item in this array contains information about the stream's current
  117. <<data-stream-write-index,write index>>.
  118. +
  119. .Properties of `indices` objects
  120. [%collapsible%open]
  121. =====
  122. `index_name`::
  123. (string)
  124. Name of the backing index. For naming conventions, see
  125. <<data-streams-generation>>.
  126. `index_uuid`::
  127. (string)
  128. Universally unique identifier (UUID) for the index.
  129. =====
  130. `generation`::
  131. (integer)
  132. Current <<data-streams-generation,generation>> for the data stream. This number
  133. acts as a cumulative count of the stream's rollovers, starting at `1`.
  134. `_meta`::
  135. (object)
  136. Custom metadata for the stream, copied from the `_meta` object of the
  137. stream's matching <<create-index-template,index template>>. If empty,
  138. the response omits this property.
  139. `status`::
  140. (string)
  141. <<cluster-health,Health status>> of the data stream.
  142. +
  143. This health status is based on the state of the primary and replica shards of
  144. the stream's backing indices.
  145. +
  146. .Values for `status`
  147. [%collapsible%open]
  148. =====
  149. `green`:::
  150. All shards are assigned.
  151. `yellow`:::
  152. All primary shards are assigned, but one or more replica shards are
  153. unassigned.
  154. `red`:::
  155. One or more primary shards are unassigned, so some data is unavailable.
  156. =====
  157. `template`::
  158. (string)
  159. Name of the index template used to create the data stream's backing indices.
  160. +
  161. The template's index pattern must match the name of this data stream. See
  162. <<create-index-template,create an index template>>.
  163. `ilm_policy`::
  164. (string)
  165. Name of the current {ilm-init} lifecycle policy in the stream's matching index
  166. template. This lifecycle policy is set in the `index.lifecycle.name` setting.
  167. +
  168. If the template does not include a lifecycle policy, this property is not
  169. included in the response.
  170. +
  171. NOTE: A data stream's backing indices may be assigned different lifecycle
  172. policies. To retrieve the lifecycle policy for individual backing indices,
  173. use the <<indices-get-settings,get index settings API>>.
  174. `hidden`::
  175. (Boolean) If `true`, the data stream is <<hidden,hidden>>.
  176. `system`::
  177. (Boolean)
  178. If `true`, the data stream is created and managed by an Elastic stack component
  179. and cannot be modified through normal user interaction.
  180. ====
  181. [[get-data-stream-api-example]]
  182. ==== {api-examples-title}
  183. [source,console]
  184. ----
  185. GET _data_stream/my-data-stream*
  186. ----
  187. The API returns the following response:
  188. [source,console-result]
  189. ----
  190. {
  191. "data_streams": [
  192. {
  193. "name": "my-data-stream",
  194. "timestamp_field": {
  195. "name": "@timestamp"
  196. },
  197. "indices": [
  198. {
  199. "index_name": ".ds-my-data-stream-2099.03.07-000001",
  200. "index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"
  201. },
  202. {
  203. "index_name": ".ds-my-data-stream-2099.03.08-000002",
  204. "index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"
  205. }
  206. ],
  207. "generation": 2,
  208. "_meta": {
  209. "my-meta-field": "foo"
  210. },
  211. "status": "GREEN",
  212. "template": "my-index-template",
  213. "ilm_policy": "my-lifecycle-policy",
  214. "hidden": false,
  215. "system": false,
  216. "allow_custom_routing": false
  217. },
  218. {
  219. "name": "my-data-stream-two",
  220. "timestamp_field": {
  221. "name": "@timestamp"
  222. },
  223. "indices": [
  224. {
  225. "index_name": ".ds-my-data-stream-two-2099.03.08-000001",
  226. "index_uuid": "3liBu2SYS5axasRt6fUIpA"
  227. }
  228. ],
  229. "generation": 1,
  230. "_meta": {
  231. "my-meta-field": "foo"
  232. },
  233. "status": "YELLOW",
  234. "template": "my-index-template",
  235. "ilm_policy": "my-lifecycle-policy",
  236. "hidden": false,
  237. "system": false,
  238. "allow_custom_routing": false
  239. }
  240. ]
  241. }
  242. ----
  243. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.07-000001"/"index_name": $body.data_streams.0.indices.0.index_name/]
  244. // TESTRESPONSE[s/"index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"/"index_uuid": $body.data_streams.0.indices.0.index_uuid/]
  245. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.08-000002"/"index_name": $body.data_streams.0.indices.1.index_name/]
  246. // TESTRESPONSE[s/"index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"/"index_uuid": $body.data_streams.0.indices.1.index_uuid/]
  247. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-two-2099.03.08-000001"/"index_name": $body.data_streams.1.indices.0.index_name/]
  248. // TESTRESPONSE[s/"index_uuid": "3liBu2SYS5axasRt6fUIpA"/"index_uuid": $body.data_streams.1.indices.0.index_uuid/]
  249. // TESTRESPONSE[s/"status": "GREEN"/"status": "YELLOW"/]