data-streams.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. [[backing-indices]]
  20. == Backing indices
  21. A data stream consists of one or more <<index-hidden,hidden>>, auto-generated
  22. backing indices.
  23. image::images/data-streams/data-streams-diagram.svg[align="center"]
  24. A data stream requires a matching <<index-templates,index template>>. The
  25. template contains the mappings and settings used to configure the stream's
  26. backing indices.
  27. // tag::timestamp-reqs[]
  28. Every document indexed to a data stream must contain a `@timestamp` field,
  29. mapped as a <<date,`date`>> or <<date_nanos,`date_nanos`>> field type. If the
  30. index template doesn't specify a mapping for the `@timestamp` field, {es} maps
  31. `@timestamp` as a `date` field with default options.
  32. // end::timestamp-reqs[]
  33. The same index template can be used for multiple data streams. You cannot
  34. delete an index template in use by a data stream.
  35. [discrete]
  36. [[data-stream-read-requests]]
  37. == Read requests
  38. When you submit a read request to a data stream, the stream routes the request
  39. to all its backing indices.
  40. image::images/data-streams/data-streams-search-request.svg[align="center"]
  41. [discrete]
  42. [[data-stream-write-index]]
  43. == Write index
  44. The most recently created backing index is the data stream’s write index.
  45. The stream adds new documents to this index only.
  46. image::images/data-streams/data-streams-index-request.svg[align="center"]
  47. You cannot add new documents to other backing indices, even by sending requests
  48. directly to the index.
  49. You also cannot perform operations on a write index that may hinder indexing,
  50. such as:
  51. * <<indices-clone-index,Clone>>
  52. * <<indices-delete-index,Delete>>
  53. * <<indices-shrink-index,Shrink>>
  54. * <<indices-split-index,Split>>
  55. [discrete]
  56. [[data-streams-rollover]]
  57. == Rollover
  58. A <<indices-rollover-index,rollover>> creates a new backing index that becomes
  59. the stream's new write index.
  60. We recommend using <<index-lifecycle-management,{ilm-init}>> to automatically
  61. roll over data streams when the write index reaches a specified age or size.
  62. If needed, you can also <<manually-roll-over-a-data-stream,manually roll over>>
  63. a data stream.
  64. [discrete]
  65. [[data-streams-generation]]
  66. == Generation
  67. Each data stream tracks its generation: a six-digit, zero-padded integer that
  68. acts as a cumulative count of the stream's rollovers, starting at `000001`.
  69. When a backing index is created, the index is named using the following
  70. convention:
  71. [source,text]
  72. ----
  73. .ds-<data-stream>-<yyyy.MM.dd>-<generation>
  74. ----
  75. `<yyyy.MM.dd>` is the backing index's creation date. Backing indices with a
  76. higher generation contain more recent data. For example, the `web-server-logs`
  77. data stream has a generation of `34`. The stream's most recent backing index,
  78. created on 7 March 2099, is named `.ds-web-server-logs-2099.03.07-000034`.
  79. Some operations, such as a <<indices-shrink-index,shrink>> or
  80. <<snapshots-restore-snapshot,restore>>, can change a backing index's name.
  81. These name changes do not remove a backing index from its data stream.
  82. [discrete]
  83. [[data-streams-append-only]]
  84. == Append-only
  85. Data streams are designed for use cases where existing data is rarely,
  86. if ever, updated. You cannot send update or deletion requests for existing
  87. documents directly to a data stream. Instead, use the
  88. <<update-docs-in-a-data-stream-by-query,update by query>> and
  89. <<delete-docs-in-a-data-stream-by-query,delete by query>> APIs.
  90. If needed, you can <<update-delete-docs-in-a-backing-index,update or delete
  91. documents>> by submitting requests directly to the document's backing index.
  92. TIP: If you frequently update or delete existing time series data, use an index
  93. alias with a write index instead of a data stream. See
  94. <<manage-time-series-data-without-data-streams>>.
  95. include::set-up-a-data-stream.asciidoc[]
  96. include::use-a-data-stream.asciidoc[]
  97. include::change-mappings-and-settings.asciidoc[]