Kibana: Data Streams, TSDS & Lifecycle

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Checked on 2026-11-09 against Kibana 9.5.x. Tested with Elasticsearch 9.5.6 and Kibana 9.5.6 in the hands-on lab (trial licence): the component template, the index template and the lifecycle request of this page were accepted; the lab has no OTLP metrics stream, so the time series check uses the aggregated APM stream.

Everything Kibana shows about a service is a query over documents, and how those documents are stored decides three things that matter to a monitoring system: how cheaply a year of metrics can be kept, how fast a dashboard over the last hour answers, and when data is deleted. Elasticsearch answers all three with data streams: append-only collections of time-stamped documents backed by a series of hidden indices, created from a template and aged by a lifecycle. This page explains that machinery as an operator of a monitoring stack needs it: the stream and its templates, the specialised time series (TSDS) and logs (LogsDB) modes, downsampling, the two lifecycle mechanisms and the Streams UI, and how to check each in the lab.

The generic index mechanics (shard sizing, aliases, general ILM) are already covered in Index Lifecycle & Scaling and mappings in Mapping & Field Types; this page stays with what monitoring adds. The cost reasoning is on Storage, Retention and Cost, the metric vocabulary (counter, gauge, histogram) on Metric Types & Aggregation, and the ways data arrives on Ingesting Monitoring Data.

Data streams and backing indices

A data stream is a named resource you write to and search, in front of a set of backing indices. The backing indices are hidden and generated; a matching index template supplies their mappings and settings. Reads go to all backing indices. Writes go only to the write index, the most recently created one, and a rollover creates a new backing index that becomes the write index. Backing indices are named .ds-<data-stream>-<yyyy.MM.dd>-<generation> with a six-digit generation such as 000034; the documentation tells you not to derive meaning from the pattern.

Three rules shape how you use a stream. Every document needs an @timestamp field mapped as date or date_nanos (the template maps it as date if you do not). The stream is append-only: you cannot send update or delete requests for existing documents to the stream itself, only to a backing index or through update by query and delete by query, which is fine for telemetry that is never edited. And a stream cannot exist without a matching template with a data_stream object, which cannot be deleted while a stream uses it. Observability data follows the naming <type>-<dataset>-<namespace> (for example logs-nginx.access-prod), described on the ingest page, so permissions and retention can target a pattern.

Index templates and component templates

A composable index template is applied when an index or data stream is created. It matches names through index_patterns, may define settings, mappings and aliases, may reference component templates through composed_of, and says whether to create a data stream. A component template is a reusable block that is never applied alone. When several templates match, the one with the highest priority wins, and there is no merging between templates. The settings of the pieces are merged in a fixed order: settings in a create-index request override the template, the template’s own settings override its components, and components listed later in composed_of override earlier ones.

Priorities are where monitoring setups break. Elastic’s built-in templates use priority 100 and Fleet integration templates go up to 200, with built-in patterns such as logs-*-*, metrics-*-*, synthetics-*-* and logs.otel.*. A custom template should either use a priority below 100 with a non-overlapping pattern or, when it must overlap a built-in pattern, use a priority above 500. Avoid @ in your own template names (it is the convention for @custom hooks) and avoid the name fleet-synced-integrations*. Legacy templates, deprecated since 7.8, only apply when no composable template matches. To extend an integration rather than replace it, use its @custom component template, which is the supported hook.

PUT _component_template/bookshelf-business-mappings
{
  "template": {
    "mappings": {
      "properties": {
        "@timestamp": { "type": "date" },
        "service.name": { "type": "keyword", "time_series_dimension": true },
        "deployment.environment": { "type": "keyword", "time_series_dimension": true },
        "bookshelf.books.created": { "type": "long", "time_series_metric": "counter" },
        "bookshelf.loans.active": { "type": "long", "time_series_metric": "gauge" }
      }
    }
  }
}

Source: Elastic: Index and component templates. The field names above are this page’s Bookshelf example, not an Elastic convention.

Time series data streams (TSDS)

A TSDS is a data stream optimised for metrics. You turn it on with index.mode: time_series in the template’s settings and mark fields:

  • a dimension (time_series_dimension: true) identifies a series; supported types are keyword, ip, byte, short, integer, long, unsigned_long and boolean, flattened fields use time_series_dimensions, and pass-through fields can simplify the definition;

  • a metric (time_series_metric) is counter (accumulates, cumulative temporality by default, delta also supported), gauge (rises and falls, numeric types and aggregate_metric_double) or histogram (value distributions, supporting histogram, tdigest and exponential_histogram, delta temporality by default).

From the dimensions Elasticsearch builds an internal _tsid and routes every document of a series to the same shard, sorts internally by _tsid and @timestamp, and stores less per document. Elastic’s benchmark for metrics reports about 70 percent less disk than a regular data stream, with the caveat that results vary by data set. Sequence numbers are disabled by default since 9.4 (re-enable with index.disable_sequence_numbers: false when update by query consistency matters), and doc values skippers are generally available since 9.3. A TSDS accepts a document only inside the time window of its backing index (writes go to the backing index whose range contains @timestamp), and loading historical data and creating past backing indices is generally available since 9.5.

The constraints follow from the model. Two documents with the same dimensions and timestamp are duplicates and the second is rejected with 409 Conflict; custom _id values are not supported; and the index.sort.* settings are not used. For monitoring this is rarely a problem, but it means a dimension that varies per request (a user id, a trace id) turns every document into its own series: cardinality is as much a TSDS problem as it is a Prometheus one, see Storage, Retention and Cost.

PUT _index_template/bookshelf-business-metrics
{
  "index_patterns": ["metrics-bookshelf.business-*"],
  "data_stream": {},
  "composed_of": ["bookshelf-business-mappings"],
  "priority": 600,
  "template": {
    "settings": { "index.mode": "time_series" },
    "lifecycle": {
      "data_retention": "30d",
      "downsampling": [ { "after": "1d", "fixed_interval": "1h" } ]
    }
  }
}

The priority of 600 is above 500 because the pattern overlaps the built-in metrics-*-* template. TSDS is generally available on Serverless Elasticsearch, Observability and Security projects and in the Elastic Stack. Querying is done with the ES|QL TS command (generally available since 9.4, preview in 9.2 and 9.3), described on Querying with KQL, ES|QL & PromQL.

Downsampling

Downsampling replaces older, less-queried time series data with a coarser version, trading resolution for storage. It works only on a TSDS and runs on each backing index: documents with the same _tsid that fall into one interval become a single document, dimensions are copied once, and metrics are reduced by the chosen method; the new index replaces the original on the same tier. A downsampled index can be downsampled again if the new interval is a multiple of the previous one.

The method decides what survives:

Method or field type What is stored

aggregate (the default)

Statistical summaries; costs more storage but keeps more information.

Gauge with aggregate

min, max, sum and value_count as an aggregate_metric_double, so avg stays exact.

Cumulative counter with aggregate

The first value, plus up to two points if a counter reset is detected (generally available since 9.4); the field type is kept.

Delta counter with aggregate

The sum of the values in the bucket (generally available since 9.5).

Histograms with aggregate

Merged into one histogram of the same type (histogram, tdigest, exponential_histogram); cumulative histograms follow the counter algorithm (generally available since 9.5).

last_value

Only the latest value per metric: smallest footprint, lowest accuracy. Preview in the Elastic Stack since 9.3, generally available on Serverless.

You configure it in the data stream lifecycle with a downsampling array (each round has after, the minimum wait after rollover, and fixed_interval) and an optional top-level downsampling_method, or in an ILM policy with downsample actions (fixed_interval and sampling_method, at most one per hot, warm or cold phase). Concurrent downsampling per stream is capped by data_streams.lifecycle.downsampling.max_indices_in_progress, default 10. ILM downsampling is unavailable on Serverless.

PUT _data_stream/metrics-bookshelf.business-default/_lifecycle
{
  "data_retention": "30d",
  "downsampling_method": "aggregate",
  "downsampling": [
    { "after": "1d", "fixed_interval": "1h" }
  ]
}

The consequence for alerting is the main design rule of this section: a rule or SLO that looks back N hours must read data that is still at full resolution. Keep after comfortably larger than the longest look-back window of any rule, and remember that a dashboard panel over a month reads the coarse interval, so a spike shorter than fixed_interval is averaged or reduced away.

LogsDB

LogsDB (index.mode: logsdb) is the storage mode for logs: Elastic’s benchmarks showed storage reductions of up to 60 percent with a 10 to 20 percent impact on indexing performance, varying with the data set and version. It is on by default for logs-*-* data streams in Serverless projects and, in the Elastic Stack, for new logs-*-* streams since 9.0. A cluster upgraded from 8.x gets it only if it had no logs-*-* streams at upgrade time, and existing 8.x streams, including integration and APM streams, are not switched automatically. To enable it elsewhere set index.mode to logsdb in the template (or in a @custom component template for an integration); it takes effect at the next rollover. Remember that a PUT of a template overwrites it, so fetch the current definition first. A related logsdb_columnar mode is a preview in the Elastic Stack since 9.5.

Data stream lifecycle and ILM

Two mechanisms age data. The data stream lifecycle is built in and focused on retention and storage: it rolls over the write index, merges older indices, applies downsampling and retention and, on the Stack, can move indices to searchable snapshots. It runs on the interval data_streams.lifecycle.poll_interval and works without hardware concepts such as tiers. Index lifecycle management (ILM) gives per-index control through the phases hot, warm, cold, frozen and delete and is tied to data tiers; it is generally available in the Elastic Stack and unavailable on Serverless, where the documentation says performance is optimised for you. Elastic recommends data streams as the default and says ILM can also manage them. The lifecycle steps beyond rollover apply to backing indices not managed by ILM (no ILM policy, or index.lifecycle.prefer_ilm set to false), so decide per stream which one owns it.

Retention is a guarantee of a minimum, not a deletion time: deletion is based on the index’s generation_time, so data may live somewhat longer. Setting it is one request, and the explain API shows which setting wins:

PUT _data_stream/logs-generic.otel-default/_lifecycle
{
  "data_retention": "14d"
}

From 9.5 on the Elastic Stack, the body can add frozen_after (for example "frozen_after": "30d" next to a longer data_retention), which needs a default snapshot repository and a suitable licence and is unavailable on Serverless; searchable-snapshot transitions in the data stream lifecycle are generally available since 9.5. In Kibana the retention is edited under Index Management (Edit data lifecycle from 9.5, Edit data retention in 9.0 to 9.4). Which lifecycle applies to OpenTelemetry data by default, and how to customise it, is on the ingest page.

Streams

Streams is a Kibana UI for parsing, organising and managing log data in data streams, with AI assistance for pattern detection and pipeline setup. A wired stream ("Ingest new data") sends logs to a managed endpoint and into a managed hierarchy with inheritance, partitioning and cascading configuration; the documentation names logs.otel and logs.ecs as the managed endpoints, and partitioning is available only for them. A classic stream ("Work with existing data") works on data already flowing into Elasticsearch with no migration. Each child stream inherits the parent’s configuration and can have its own retention, processing and mappings. The Processing tab builds a pipeline that extracts fields, the Data lifecycle tab sets retention (inherit, a minimum period, or an ILM policy), and the page shows a data quality status (good, degraded or poor) and keeps ingestion failures in a failure store.

Streams is generally available on Serverless and in the Elastic Stack since 9.2 (preview in 9.1); partitioning remains a preview. The AI features need a generative AI connector (Elastic Managed LLMs work without an external key). Use it when the log shape is the problem, for example Bookshelf’s JSON logs landing as one message string; for a clean OpenTelemetry stream it adds little.

Source: Elastic: Streams.

Verify it in the lab

  1. In Dev Tools run GET _data_stream/*.otel-* and note the template, ilm_policy or lifecycle and the number of backing indices of each stream created by the EDOT Collector.

  2. Run GET _data_stream/metrics-service_transaction.1m.otel-default and check index_mode: it is time_series for the metrics stream (the lab has no OTLP metrics stream, so this aggregated APM stream stands in), while the logs and traces streams report logsdb.

  3. Create the component template and index template of this page, then index a document with POST metrics-bookshelf.business-default/_doc with an @timestamp of now, service.name of bookshelf, a deployment.environment of lab and the two metric fields. Repeat the identical document and observe the 409 caused by duplicate dimensions and timestamp.

  4. Run PUT _data_stream/metrics-bookshelf.business-default/_lifecycle with the body above and then GET metrics-bookshelf.business-default/_lifecycle/explain; expect managed_by_lifecycle: true.

  5. Force a rollover with POST metrics-bookshelf.business-default/_rollover and list the two backing indices with GET _data_stream/metrics-bookshelf.business-default.

  6. In Kibana open Stack Management, Index Management, Data Streams and check the same information, including the lifecycle column and the storage size.

What can go wrong

  • A custom template never applies. A built-in template with a higher priority wins; raise the priority above 500 for a pattern that overlaps metrics-*-* or logs-*-*.

  • Rejected documents with a 409. Identical dimension values and timestamp in a TSDS are duplicates; add a distinguishing dimension only if it is stable, never a per-request value.

  • Cardinality explosion. One high-cardinality dimension multiplies the series count; keep identifiers out of dimensions.

  • Alerts that go blind. A rule window shorter than the downsampling after is safe; a longer one reads coarse data.

  • Data kept forever. OpenTelemetry and many other streams have no default delete; set retention explicitly.

  • Two lifecycles disagreeing. A stream with an ILM policy and a lifecycle is managed by ILM unless prefer_ilm is false.

  • Serverless differences. No ILM, no ILM downsampling, no frozen_after: write the Serverless variant with the data stream lifecycle only.

In the books

Saurabh Chhajed’s Learning ELK Stack (chapter 9, data retention) tells the reader to define a retention policy up front and to delete old indices on a schedule with Elasticsearch Curator, running a command from cron that removes daily indices older than a number of days. That book predates data streams, TSDS, downsampling, LogsDB and the data stream lifecycle, which together replace the daily-index-plus-Curator pattern: today you describe the stream once in a template and let the lifecycle roll over, downsample and delete. The advice to decide retention before the data arrives is still right, and Curator is no longer needed for it. The aggregation vocabulary taught in the other Elasticsearch books still applies to queries over these streams; see Metric Types & Aggregation.

Where to go next