| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 | [role="xpack"][[data-streams]]= Data streams++++<titleabbrev>Data streams</titleabbrev>++++A data stream lets you store append-only time seriesdata across multiple indices while giving you a single named resource forrequests. Data streams are well-suited for logs, events, metrics, and othercontinuously generated data.You can submit indexing and search requests directly to a data stream. Thestream automatically routes the request to backing indices that store thestream's data. You can use <<index-lifecycle-management,{ilm} ({ilm-init})>> toautomate the management of these backing indices. For example, you can use{ilm-init} to automatically move older backing indices to less expensivehardware and delete unneeded indices. {ilm-init} can help you reduce costs andoverhead as your data grows.[discrete][[backing-indices]]== Backing indicesA data stream consists of one or more <<index-hidden,hidden>>, auto-generatedbacking indices.image::images/data-streams/data-streams-diagram.svg[align="center"]A data stream requires a matching <<index-templates,index template>>. Thetemplate contains the mappings and settings used to configure the stream'sbacking indices.// tag::timestamp-reqs[]Every document indexed to a data stream must contain a `@timestamp` field,mapped as a <<date,`date`>> or <<date_nanos,`date_nanos`>> field type. If theindex template doesn't specify a mapping for the `@timestamp` field, {es} maps`@timestamp` as a `date` field with default options.// end::timestamp-reqs[]The same index template can be used for multiple data streams. You cannotdelete an index template in use by a data stream.[discrete][[data-stream-read-requests]]== Read requestsWhen you submit a read request to a data stream, the stream routes the requestto all its backing indices.image::images/data-streams/data-streams-search-request.svg[align="center"][discrete][[data-stream-write-index]]== Write indexThe most recently created backing index is the data stream’s write index.The stream adds new documents to this index only.image::images/data-streams/data-streams-index-request.svg[align="center"]You cannot add new documents to other backing indices, even by sending requestsdirectly to the index.You also cannot perform operations on a write index that may hinder indexing,such as:* <<indices-clone-index,Clone>>* <<indices-delete-index,Delete>>* <<indices-shrink-index,Shrink>>* <<indices-split-index,Split>>[discrete][[data-streams-rollover]]== RolloverA <<indices-rollover-index,rollover>> creates a new backing index that becomesthe stream's new write index.We recommend using <<index-lifecycle-management,{ilm-init}>> to automaticallyroll over data streams when the write index reaches a specified age or size.If needed, you can also <<manually-roll-over-a-data-stream,manually roll over>>a data stream.[discrete][[data-streams-generation]]== GenerationEach data stream tracks its generation: a six-digit, zero-padded integer thatacts as a cumulative count of the stream's rollovers, starting at `000001`.When a backing index is created, the index is named using the followingconvention:[source,text]----.ds-<data-stream>-<yyyy.MM.dd>-<generation>----`<yyyy.MM.dd>` is the backing index's creation date. Backing indices with ahigher generation contain more recent data. For example, the `web-server-logs`data stream has a generation of `34`. The stream's most recent backing index,created on 7 March 2099, is named `.ds-web-server-logs-2099.03.07-000034`.Some operations, such as a <<indices-shrink-index,shrink>> or<<snapshots-restore-snapshot,restore>>, can change a backing index's name.These name changes do not remove a backing index from its data stream.[discrete][[data-streams-append-only]]== Append-onlyData streams are designed for use cases where existing data is rarely,if ever, updated. You cannot send update or deletion requests for existingdocuments directly to a data stream. Instead, use the<<update-docs-in-a-data-stream-by-query,update by query>> and<<delete-docs-in-a-data-stream-by-query,delete by query>> APIs.If needed, you can <<update-delete-docs-in-a-backing-index,update or deletedocuments>> by submitting requests directly to the document's backing index.TIP: If you frequently update or delete existing time series data, use an indexalias with a write index instead of a data stream. See<<manage-time-series-data-without-data-streams>>.include::set-up-a-data-stream.asciidoc[]include::use-a-data-stream.asciidoc[]include::change-mappings-and-settings.asciidoc[]
 |