data-streams.asciidoc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. [role="xpack"]
  2. [[data-streams]]
  3. = Data streams
  4. ++++
  5. <titleabbrev>Data streams</titleabbrev>
  6. ++++
  7. A data stream lets you store append-only time series
  8. data across multiple indices while giving you a single named resource for
  9. requests. Data streams are well-suited for logs, events, metrics, and other
  10. continuously generated data.
  11. You can submit indexing and search requests directly to a data stream. The
  12. stream automatically routes the request to backing indices that store the
  13. stream's data. You can use <<index-lifecycle-management,{ilm} ({ilm-init})>> to
  14. automate the management of these backing indices. For example, you can use
  15. {ilm-init} to automatically move older backing indices to less expensive
  16. hardware and delete unneeded indices. {ilm-init} can help you reduce costs and
  17. overhead as your data grows.
  18. [discrete]
  19. [[should-you-use-a-data-stream]]
  20. == Should you use a data stream?
  21. To determine whether you should use a data stream for your data, you should consider the format of
  22. the data, and your expected interaction. A good candidate for using a data stream will match the
  23. following criteria:
  24. * Your data contains a timestamp field, or one could be automatically generated.
  25. * You mostly perform indexing requests, with occasional updates and deletes.
  26. * You index documents without an `_id`, or when indexing documents with an explicit `_id` you expect first-write-wins behavior.
  27. For most time series data use-cases, a data stream will be a good fit. However, if you find that
  28. your data doesn't fit into these categories (for example, if you frequently send multiple documents
  29. using the same `_id` expecting last-write-wins), you may want to use an index alias with a write
  30. index instead. See documentation for <<manage-time-series-data-without-data-streams,managing time
  31. series data without a data stream>> for more information.
  32. Keep in mind that some features such as <<tsds,Time Series Data Streams (TSDS)>> and
  33. <<data-stream-lifecycle,data stream lifecycles>> require a data stream.
  34. [discrete]
  35. [[backing-indices]]
  36. == Backing indices
  37. A data stream consists of one or more <<index-hidden,hidden>>, auto-generated
  38. backing indices.
  39. image::images/data-streams/data-streams-diagram.svg[align="center"]
  40. A data stream requires a matching <<index-templates,index template>>. The
  41. template contains the mappings and settings used to configure the stream's
  42. backing indices.
  43. // tag::timestamp-reqs[]
  44. Every document indexed to a data stream must contain a `@timestamp` field,
  45. mapped as a <<date,`date`>> or <<date_nanos,`date_nanos`>> field type. If the
  46. index template doesn't specify a mapping for the `@timestamp` field, {es} maps
  47. `@timestamp` as a `date` field with default options.
  48. // end::timestamp-reqs[]
  49. The same index template can be used for multiple data streams. You cannot
  50. delete an index template in use by a data stream.
  51. The name pattern for the backing indices is an implementation detail and no
  52. intelligence should be derived from it. The only invariant the holds is that
  53. each data stream generation index will have a unique name.
  54. [discrete]
  55. [[data-stream-read-requests]]
  56. == Read requests
  57. When you submit a read request to a data stream, the stream routes the request
  58. to all its backing indices.
  59. image::images/data-streams/data-streams-search-request.svg[align="center"]
  60. [discrete]
  61. [[data-stream-write-index]]
  62. == Write index
  63. The most recently created backing index is the data stream’s write index.
  64. The stream adds new documents to this index only.
  65. image::images/data-streams/data-streams-index-request.svg[align="center"]
  66. You cannot add new documents to other backing indices, even by sending requests
  67. directly to the index.
  68. You also cannot perform operations on a write index that may hinder indexing,
  69. such as:
  70. * <<indices-clone-index,Clone>>
  71. * <<indices-delete-index,Delete>>
  72. * <<indices-shrink-index,Shrink>>
  73. * <<indices-split-index,Split>>
  74. [discrete]
  75. [[data-streams-rollover]]
  76. == Rollover
  77. A <<indices-rollover-index,rollover>> creates a new backing index that becomes
  78. the stream's new write index.
  79. We recommend using <<index-lifecycle-management,{ilm-init}>> to automatically
  80. roll over data streams when the write index reaches a specified age or size.
  81. If needed, you can also <<manually-roll-over-a-data-stream,manually roll over>>
  82. a data stream.
  83. [discrete]
  84. [[data-streams-generation]]
  85. == Generation
  86. Each data stream tracks its generation: a six-digit, zero-padded integer starting at `000001`.
  87. When a backing index is created, the index is named using the following
  88. convention:
  89. [source,text]
  90. ----
  91. .ds-<data-stream>-<yyyy.MM.dd>-<generation>
  92. ----
  93. `<yyyy.MM.dd>` is the backing index's creation date. Backing indices with a
  94. higher generation contain more recent data. For example, the `web-server-logs`
  95. data stream has a generation of `34`. The stream's most recent backing index,
  96. created on 7 March 2099, is named `.ds-web-server-logs-2099.03.07-000034`.
  97. Some operations, such as a <<indices-shrink-index,shrink>> or
  98. <<snapshots-restore-snapshot,restore>>, can change a backing index's name.
  99. These name changes do not remove a backing index from its data stream.
  100. The generation of the data stream can change without a new index being added to
  101. the data stream (e.g. when an existing backing index is shrunk). This means the
  102. backing indices for some generations will never exist.
  103. You should not derive any intelligence from the backing indices names.
  104. [discrete]
  105. [[data-streams-append-only]]
  106. == Append-only (mostly)
  107. Data streams are designed for use cases where existing data is rarely updated. You cannot send
  108. update or deletion requests for existing documents directly to a data stream. However, you can still
  109. <<update-delete-docs-in-a-backing-index,update or delete documents>> in a data stream by submitting
  110. requests directly to the document's backing index.
  111. If you need to update a larger number of documents in a data stream, you can use the
  112. <<update-docs-in-a-data-stream-by-query,update by query>> and
  113. <<delete-docs-in-a-data-stream-by-query,delete by query>> APIs.
  114. TIP: If you frequently send multiple documents using the same `_id` expecting last-write-wins, you
  115. may want to use an index alias with a write index instead. See
  116. <<manage-time-series-data-without-data-streams>>.
  117. include::set-up-a-data-stream.asciidoc[]
  118. include::use-a-data-stream.asciidoc[]
  119. include::change-mappings-and-settings.asciidoc[]
  120. include::tsds.asciidoc[]
  121. include::logs.asciidoc[]
  122. include::lifecycle/index.asciidoc[]