data-streams.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. Each data stream requires a matching <<indices-templates,index template>>. The
  25. template contains the mappings and settings used to configure the stream's
  26. backing indices.
  27. Every document indexed to a data stream must contain a `@timestamp` field,
  28. mapped as a <<date,`date`>> or <<date_nanos,`date_nanos`>> field type. If the
  29. index template doesn't specify a mapping for the `@timestamp` field, {es} maps
  30. `@timestamp` as a `date` field with default options.
  31. The same index template can be used for multiple data streams. You cannot
  32. delete an index template in use by a data stream.
  33. [discrete]
  34. [[data-stream-read-requests]]
  35. == Read requests
  36. When you submit a read request to a data stream, the stream routes the request
  37. to all its backing indices.
  38. image::images/data-streams/data-streams-search-request.svg[align="center"]
  39. [discrete]
  40. [[data-stream-write-index]]
  41. == Write index
  42. The most recently created backing index is the data stream’s write index.
  43. The stream adds new documents to this index only.
  44. image::images/data-streams/data-streams-index-request.svg[align="center"]
  45. You cannot add new documents to other backing indices, even by sending requests
  46. directly to the index.
  47. You also cannot perform operations on a write index that may hinder indexing,
  48. such as:
  49. * <<indices-clone-index,Clone>>
  50. * <<indices-close,Close>>
  51. * <<indices-delete-index,Delete>>
  52. * <<freeze-index-api,Freeze>>
  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>-<generation>
  74. ----
  75. Backing indices with a higher generation contain more recent data. For example,
  76. the `web-server-logs` data stream has a generation of `34`. The stream's most
  77. recent backing index is named `.ds-web-server-logs-000034`.
  78. Some operations, such as a <<indices-shrink-index,shrink>> or
  79. <<snapshots-restore-snapshot,restore>>, can change a backing index's name.
  80. These name changes do not remove a backing index from its data stream.
  81. [discrete]
  82. [[data-streams-append-only]]
  83. == Append-only
  84. Data streams are designed for use cases where existing data is rarely,
  85. if ever, updated. You cannot send update or deletion requests for existing
  86. documents directly to a data stream. Instead, use the
  87. <<update-docs-in-a-data-stream-by-query,update by query>> and
  88. <<delete-docs-in-a-data-stream-by-query,delete by query>> APIs.
  89. If needed, you can <<update-delete-docs-in-a-backing-index,update or delete
  90. documents>> by submitting requests directly to the document's backing index.
  91. TIP: If you frequently update or delete existing documents, use an
  92. <<indices-add-alias,index alias>> and <<indices-templates,index template>>
  93. instead of a data stream. You can still use
  94. <<index-lifecycle-management,{ilm-init}>> to manage indices for the alias.
  95. include::set-up-a-data-stream.asciidoc[]
  96. include::use-a-data-stream.asciidoc[]
  97. include::change-mappings-and-settings.asciidoc[]