get-data-stream.asciidoc 10 KB

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