get-data-stream.asciidoc 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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. `include_defaults`::
  86. (Optional, Boolean) Functionality in preview:[]. If `true`, return all default settings in the response.
  87. Defaults to `false`.
  88. [role="child_attributes"]
  89. [[get-data-stream-api-response-body]]
  90. ==== {api-response-body-title}
  91. `data_streams`::
  92. (array of objects)
  93. Contains information about retrieved data streams.
  94. +
  95. .Properties of objects in `data_streams`
  96. [%collapsible%open]
  97. ====
  98. `name`::
  99. (string)
  100. Name of the data stream.
  101. `timestamp_field`::
  102. (object)
  103. Contains information about the data stream's `@timestamp` field.
  104. +
  105. .Properties of `timestamp_field`
  106. [%collapsible%open]
  107. =====
  108. `name`::
  109. (string)
  110. Name of the data stream's timestamp field, which must be `@timestamp`. The
  111. `@timestamp` field must be included in every document indexed to the data
  112. stream.
  113. =====
  114. `indices`::
  115. (array of objects)
  116. Array of objects containing information about the data stream's backing
  117. indices.
  118. +
  119. The last item in this array contains information about the stream's current
  120. <<data-stream-write-index,write index>>.
  121. +
  122. .Properties of `indices` objects
  123. [%collapsible%open]
  124. =====
  125. `index_name`::
  126. (string)
  127. Name of the backing index. For naming conventions, see
  128. <<data-streams-generation>>.
  129. `index_uuid`::
  130. (string)
  131. Universally unique identifier (UUID) for the index.
  132. =====
  133. `generation`::
  134. (integer)
  135. Current <<data-streams-generation,generation>> for the data stream. This number
  136. acts as a cumulative count of the stream's rollovers, starting at `1`.
  137. `_meta`::
  138. (object)
  139. Custom metadata for the stream, copied from the `_meta` object of the
  140. stream's matching <<create-index-template,index template>>. If empty,
  141. the response omits this property.
  142. `status`::
  143. (string)
  144. <<cluster-health,Health status>> of the data stream.
  145. +
  146. This health status is based on the state of the primary and replica shards of
  147. the stream's backing indices.
  148. +
  149. .Values for `status`
  150. [%collapsible%open]
  151. =====
  152. `GREEN`:::
  153. All shards are assigned.
  154. `YELLOW`:::
  155. All primary shards are assigned, but one or more replica shards are
  156. unassigned.
  157. `RED`:::
  158. One or more primary shards are unassigned, so some data is unavailable.
  159. =====
  160. `template`::
  161. (string)
  162. Name of the index template used to create the data stream's backing indices.
  163. +
  164. The template's index pattern must match the name of this data stream. See
  165. <<create-index-template,create an index template>>.
  166. `ilm_policy`::
  167. (string)
  168. Name of the current {ilm-init} lifecycle policy in the stream's matching index
  169. template. This lifecycle policy is set in the `index.lifecycle.name` setting.
  170. +
  171. If the template does not include a lifecycle policy, this property is not
  172. included in the response.
  173. +
  174. NOTE: A data stream's backing indices may be assigned different lifecycle
  175. policies. To retrieve the lifecycle policy for individual backing indices,
  176. use the <<indices-get-settings,get index settings API>>.
  177. `hidden`::
  178. (Boolean) If `true`, the data stream is <<multi-hidden,hidden>>.
  179. `system`::
  180. (Boolean)
  181. If `true`, the data stream is created and managed by an Elastic stack component
  182. and cannot be modified through normal user interaction.
  183. `allow_custom_routing`::
  184. (Boolean)
  185. If `true`, the data stream this data stream allows custom routing on write request.
  186. `replicated`::
  187. (Boolean)
  188. If `true`, the data stream is created and managed by {ccr} and the local
  189. cluster can not write into this data stream or change its mappings.
  190. `lifecycle`::
  191. (object)
  192. Functionality in preview:[]. Contains the configuration for the data lifecycle management of this data stream.
  193. +
  194. .Properties of `lifecycle`
  195. [%collapsible%open]
  196. =====
  197. `data_retention`::
  198. (string)
  199. If defined, every document added to this data stream will be stored at least for this time frame. Any time after this
  200. duration the document could be deleted. When empty, every document in this data stream will be stored indefinitely.
  201. `rollover`::
  202. (object)
  203. The conditions which will trigger the rollover of a backing index as configured by the cluster setting
  204. `cluster.lifecycle.default.rollover`. This property is an implementation detail and it will only be retrieved when the query
  205. param `include_defaults` is set to `true`. The contents of this field are subject to change.
  206. =====
  207. ====
  208. [[get-data-stream-api-example]]
  209. ==== {api-examples-title}
  210. [source,console]
  211. ----
  212. GET _data_stream/my-data-stream*
  213. ----
  214. The API returns the following response:
  215. [source,console-result]
  216. ----
  217. {
  218. "data_streams": [
  219. {
  220. "name": "my-data-stream",
  221. "timestamp_field": {
  222. "name": "@timestamp"
  223. },
  224. "indices": [
  225. {
  226. "index_name": ".ds-my-data-stream-2099.03.07-000001",
  227. "index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"
  228. },
  229. {
  230. "index_name": ".ds-my-data-stream-2099.03.08-000002",
  231. "index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"
  232. }
  233. ],
  234. "generation": 2,
  235. "_meta": {
  236. "my-meta-field": "foo"
  237. },
  238. "status": "GREEN",
  239. "template": "my-index-template",
  240. "ilm_policy": "my-lifecycle-policy",
  241. "hidden": false,
  242. "system": false,
  243. "allow_custom_routing": false,
  244. "replicated": false
  245. },
  246. {
  247. "name": "my-data-stream-two",
  248. "timestamp_field": {
  249. "name": "@timestamp"
  250. },
  251. "indices": [
  252. {
  253. "index_name": ".ds-my-data-stream-two-2099.03.08-000001",
  254. "index_uuid": "3liBu2SYS5axasRt6fUIpA"
  255. }
  256. ],
  257. "generation": 1,
  258. "_meta": {
  259. "my-meta-field": "foo"
  260. },
  261. "status": "YELLOW",
  262. "template": "my-index-template",
  263. "ilm_policy": "my-lifecycle-policy",
  264. "hidden": false,
  265. "system": false,
  266. "allow_custom_routing": false,
  267. "replicated": false
  268. }
  269. ]
  270. }
  271. ----
  272. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.07-000001"/"index_name": $body.data_streams.0.indices.0.index_name/]
  273. // TESTRESPONSE[s/"index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"/"index_uuid": $body.data_streams.0.indices.0.index_uuid/]
  274. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.08-000002"/"index_name": $body.data_streams.0.indices.1.index_name/]
  275. // TESTRESPONSE[s/"index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"/"index_uuid": $body.data_streams.0.indices.1.index_uuid/]
  276. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-two-2099.03.08-000001"/"index_name": $body.data_streams.1.indices.0.index_name/]
  277. // TESTRESPONSE[s/"index_uuid": "3liBu2SYS5axasRt6fUIpA"/"index_uuid": $body.data_streams.1.indices.0.index_uuid/]
  278. // TESTRESPONSE[s/"status": "GREEN"/"status": "YELLOW"/]