get-data-stream.asciidoc 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  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. DELETE /_data_stream/my-data-stream*/_lifecycle
  49. ----
  50. // TESTSETUP
  51. ////
  52. ////
  53. [source,console]
  54. ----
  55. DELETE /_data_stream/*
  56. DELETE /_index_template/*
  57. DELETE /_ilm/policy/my-lifecycle-policy
  58. ----
  59. // TEARDOWN
  60. ////
  61. [source,console]
  62. ----
  63. GET /_data_stream/my-data-stream
  64. ----
  65. [[get-data-stream-api-request]]
  66. ==== {api-request-title}
  67. `GET /_data_stream/<data-stream>`
  68. [[get-data-stream-api-prereqs]]
  69. ==== {api-prereq-title}
  70. * If the {es} {security-features} are enabled, you must have the
  71. `view_index_metadata` or `manage` <<privileges-list-indices,index privilege>>
  72. for the 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-query-parms]]
  82. ==== {api-query-parms-title}
  83. include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=ds-expand-wildcards]
  84. +
  85. Defaults to `open`.
  86. `include_defaults`::
  87. (Optional, Boolean) Functionality in preview:[]. If `true`, return all default settings in the response.
  88. Defaults to `false`.
  89. [role="child_attributes"]
  90. [[get-data-stream-api-response-body]]
  91. ==== {api-response-body-title}
  92. `data_streams`::
  93. (array of objects)
  94. Contains information about retrieved data streams.
  95. +
  96. .Properties of objects in `data_streams`
  97. [%collapsible%open]
  98. ====
  99. `name`::
  100. (string)
  101. Name of the data stream.
  102. `timestamp_field`::
  103. (object)
  104. Contains information about the data stream's `@timestamp` field.
  105. +
  106. .Properties of `timestamp_field`
  107. [%collapsible%open]
  108. =====
  109. `name`::
  110. (string)
  111. Name of the data stream's timestamp field, which must be `@timestamp`. The
  112. `@timestamp` field must be included in every document indexed to the data
  113. stream.
  114. =====
  115. `indices`::
  116. (array of objects)
  117. Array of objects containing information about the data stream's backing
  118. indices.
  119. +
  120. The last item in this array contains information about the stream's current
  121. <<data-stream-write-index,write index>>.
  122. +
  123. .Properties of `indices` objects
  124. [%collapsible%open]
  125. =====
  126. `index_name`::
  127. (string)
  128. Name of the backing index. For naming conventions, see
  129. <<data-streams-generation>>.
  130. `index_uuid`::
  131. (string)
  132. Universally unique identifier (UUID) for the index.
  133. `prefer_ilm`::
  134. (boolean)
  135. Functionality in preview:[]. Indicates if this index is configured to prefer {ilm}
  136. when both {ilm-cap} and <<data-stream-lifecycle, Data stream lifecycle>> are configured to
  137. manage this index.
  138. `managed_by`::
  139. (string)
  140. Functionality in preview:[]. Indicates the system that managed this index.
  141. =====
  142. `generation`::
  143. (integer)
  144. Current <<data-streams-generation,generation>> for the data stream. This number
  145. acts as a cumulative count of the stream's rollovers, starting at `1`.
  146. `_meta`::
  147. (object)
  148. Custom metadata for the stream, copied from the `_meta` object of the
  149. stream's matching <<create-index-template,index template>>. If empty,
  150. the response omits this property.
  151. `status`::
  152. (string)
  153. <<cluster-health,Health status>> of the data stream.
  154. +
  155. This health status is based on the state of the primary and replica shards of
  156. the stream's backing indices.
  157. +
  158. .Values for `status`
  159. [%collapsible%open]
  160. =====
  161. `GREEN`:::
  162. All shards are assigned.
  163. `YELLOW`:::
  164. All primary shards are assigned, but one or more replica shards are
  165. unassigned.
  166. `RED`:::
  167. One or more primary shards are unassigned, so some data is unavailable.
  168. =====
  169. `template`::
  170. (string)
  171. Name of the index template used to create the data stream's backing indices.
  172. +
  173. The template's index pattern must match the name of this data stream. See
  174. <<create-index-template,create an index template>>.
  175. `ilm_policy`::
  176. (string)
  177. Name of the current {ilm-init} lifecycle policy in the stream's matching index
  178. template. This lifecycle policy is set in the `index.lifecycle.name` setting.
  179. +
  180. If the template does not include a lifecycle policy, this property is not
  181. included in the response.
  182. +
  183. NOTE: A data stream's backing indices may be assigned different lifecycle
  184. policies. To retrieve the lifecycle policy for individual backing indices,
  185. use the <<indices-get-settings,get index settings API>>.
  186. `next_generation_managed_by`::
  187. (string)
  188. Functionality in preview:[]. Indicates the system that will managed the next generation index
  189. (i.e. the next data stream write index).
  190. `prefer_ilm`::
  191. (boolean)
  192. Functionality in preview:[]. Indicates if the index template used to create the data
  193. stream's backing indices is configured to prefer {ilm-cap} when both {ilm-cap} and
  194. <<data-stream-lifecycle, Data stream lifecycle>> are configured to manage this index.
  195. `hidden`::
  196. (Boolean) If `true`, the data stream is <<multi-hidden,hidden>>.
  197. `system`::
  198. (Boolean)
  199. If `true`, the data stream is created and managed by an Elastic stack component
  200. and cannot be modified through normal user interaction.
  201. `allow_custom_routing`::
  202. (Boolean)
  203. If `true`, the data stream this data stream allows custom routing on write request.
  204. `replicated`::
  205. (Boolean)
  206. If `true`, the data stream is created and managed by {ccr} and the local
  207. cluster can not write into this data stream or change its mappings.
  208. `lifecycle`::
  209. (object)
  210. Functionality in preview:[]. Contains the configuration for the data stream lifecycle management of this data stream.
  211. +
  212. .Properties of `lifecycle`
  213. [%collapsible%open]
  214. =====
  215. `data_retention`::
  216. (string)
  217. If defined, every document added to this data stream will be stored at least for this time frame. Any time after this
  218. duration the document could be deleted. When empty, every document in this data stream will be stored indefinitely.
  219. `rollover`::
  220. (object)
  221. The conditions which will trigger the rollover of a backing index as configured by the cluster setting
  222. `cluster.lifecycle.default.rollover`. This property is an implementation detail and it will only be retrieved when the query
  223. param `include_defaults` is set to `true`. The contents of this field are subject to change.
  224. =====
  225. `rollover_on_write`::
  226. (Boolean)
  227. If `true`, the next write to this data stream will trigger a rollover first and the document will be
  228. indexed in the new backing index. If the rollover fails the indexing request will fail too.
  229. ====
  230. [[get-data-stream-api-example]]
  231. ==== {api-examples-title}
  232. [source,console]
  233. ----
  234. GET _data_stream/my-data-stream*
  235. ----
  236. The API returns the following response:
  237. [source,console-result]
  238. ----
  239. {
  240. "data_streams": [
  241. {
  242. "name": "my-data-stream",
  243. "timestamp_field": {
  244. "name": "@timestamp"
  245. },
  246. "indices": [
  247. {
  248. "index_name": ".ds-my-data-stream-2099.03.07-000001",
  249. "index_uuid": "xCEhwsp8Tey0-FLNFYVwSg",
  250. "prefer_ilm": true,
  251. "ilm_policy": "my-lifecycle-policy",
  252. "managed_by": "Index Lifecycle Management"
  253. },
  254. {
  255. "index_name": ".ds-my-data-stream-2099.03.08-000002",
  256. "index_uuid": "PA_JquKGSiKcAKBA8DJ5gw",
  257. "prefer_ilm": true,
  258. "ilm_policy": "my-lifecycle-policy",
  259. "managed_by": "Index Lifecycle Management"
  260. }
  261. ],
  262. "generation": 2,
  263. "_meta": {
  264. "my-meta-field": "foo"
  265. },
  266. "status": "GREEN",
  267. "next_generation_managed_by": "Index Lifecycle Management",
  268. "prefer_ilm": true,
  269. "template": "my-index-template",
  270. "ilm_policy": "my-lifecycle-policy",
  271. "hidden": false,
  272. "system": false,
  273. "allow_custom_routing": false,
  274. "replicated": false,
  275. "rollover_on_write": false
  276. },
  277. {
  278. "name": "my-data-stream-two",
  279. "timestamp_field": {
  280. "name": "@timestamp"
  281. },
  282. "indices": [
  283. {
  284. "index_name": ".ds-my-data-stream-two-2099.03.08-000001",
  285. "index_uuid": "3liBu2SYS5axasRt6fUIpA",
  286. "prefer_ilm": true,
  287. "ilm_policy": "my-lifecycle-policy",
  288. "managed_by": "Index Lifecycle Management"
  289. }
  290. ],
  291. "generation": 1,
  292. "_meta": {
  293. "my-meta-field": "foo"
  294. },
  295. "status": "YELLOW",
  296. "next_generation_managed_by": "Index Lifecycle Management",
  297. "prefer_ilm": true,
  298. "template": "my-index-template",
  299. "ilm_policy": "my-lifecycle-policy",
  300. "hidden": false,
  301. "system": false,
  302. "allow_custom_routing": false,
  303. "replicated": false,
  304. "rollover_on_write": false
  305. }
  306. ]
  307. }
  308. ----
  309. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.07-000001"/"index_name": $body.data_streams.0.indices.0.index_name/]
  310. // TESTRESPONSE[s/"index_uuid": "xCEhwsp8Tey0-FLNFYVwSg"/"index_uuid": $body.data_streams.0.indices.0.index_uuid/]
  311. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-2099.03.08-000002"/"index_name": $body.data_streams.0.indices.1.index_name/]
  312. // TESTRESPONSE[s/"index_uuid": "PA_JquKGSiKcAKBA8DJ5gw"/"index_uuid": $body.data_streams.0.indices.1.index_uuid/]
  313. // TESTRESPONSE[s/"index_name": ".ds-my-data-stream-two-2099.03.08-000001"/"index_name": $body.data_streams.1.indices.0.index_name/]
  314. // TESTRESPONSE[s/"index_uuid": "3liBu2SYS5axasRt6fUIpA"/"index_uuid": $body.data_streams.1.indices.0.index_uuid/]
  315. // TESTRESPONSE[s/"status": "GREEN"/"status": "YELLOW"/]
  316. // TESTRESPONSE[s/"replicated": false/"replicated": false,"failure_store":{"enabled": false, "indices": [], "rollover_on_write": false}/]