Metric temporality
When working with counters and histograms in a time series data stream (TSDS), the temporality of a metric determines how its values relate to one another over time. Elasticsearch supports two temporality models: cumulative and delta.
Understanding temporality is important because it affects how Elasticsearch interprets metric values during queries, aggregations, and downsampling.
The difference between cumulative and delta temporality is best explained with a counter metric that tracks the number of HTTP requests a server has handled.
With cumulative temporality, each data point represents the total count since the process started. The values are monotonically increasing (or reset to zero when the process restarts).
| Timestamp | Value | Meaning |
|---|---|---|
| 10:01 | 27 | 27 total requests since start |
| 10:02 | 72 | 72 total requests since start |
| 10:03 | 113 | 113 total requests since start |
To determine the rate of change, Elasticsearch computes the difference between consecutive values. Between 10:01 and 10:02, the total number of requests increased by 45.
Therefore, the increase function yields 45 for this time interval. rate divides the total increase by the time interval in seconds. This yields 0.75 requests per second in this case, because the time range between 10:01 and 10:02 is 60 seconds.
This is the default temporality for counter metrics in Elasticsearch.
With delta temporality, each data point represents the change since the previous measurement. The values are independent of one another.
| Timestamp | Value | Meaning |
|---|---|---|
| 10:01 | 27 | 27 new requests in this interval |
| 10:02 | 45 | 45 new requests in this interval |
| 10:03 | 41 | 41 new requests in this interval |
To determine the rate of change, Elasticsearch uses the value directly.
This means that for the time interval between 10:01 and 10:02, as with cumulative temporality, increase yields 45 and rate 0.75.
This is the default temporality for histogram metrics in Elasticsearch.
How you configure temporality depends on the ingestion path. The OTLP endpoints and Prometheus remote write need no configuration. If you ingest metrics into custom indices, you set a temporality field on the data stream.
You don't have to configure anything for these ingestion paths:
OTLP. The Elasticsearch OTLP endpoint and Elastic Cloud Managed OTLP Endpoint both come with a
temporalitydimension preconfigured in the mappings. They preserve the temporality of ingested metrics from the OTLP temporality metadata.On Elastic Cloud Hosted, the Elastic Cloud Managed OTLP Endpoint preserves temporality for deployments running Elastic Stack 9.5.3 or later.
Prometheus remote write. Prometheus remote write V1 supports only counters and classic Prometheus histograms (represented as counters), which are always cumulative. Because this matches the default temporality for counters, the Elasticsearch remote write endpoint doesn't set up a temporality field.
For temporality support across all ingestion paths and deployment types, refer to Histogram and counter temporality.
If you ingest metrics into custom indices, for example using _bulk, set index.time_series.temporality_field on the data stream. This setting names the field that stores the temporality of each document.
You don't need to define the mapping for this field yourself. Elasticsearch creates it from the index setting. If you do map the field, it must:
Set the field to one of these values:
delta: metrics in the document use delta temporality.cumulative: metrics in the document use cumulative temporality.
If the field is absent or contains any other value, Elasticsearch uses the default temporality for each metric type: cumulative for counters and delta for histograms.
Because temporality is a dimension, a metric can mix temporalities. Some time series can use delta while others use cumulative. Queries and downsampling handle this automatically.
The temporality field is used automatically by PromQL and ES|QL time series queries. When you query a TSDS using the TS command, Elasticsearch reads each document's temporality value and adjusts the behavior of supported time series aggregation functions accordingly:
- Cumulative metrics: Elasticsearch computes the difference between consecutive values to determine the rate of change.
- Delta metrics: Elasticsearch uses the values directly, since they already represent changes.
The supported functions respecting the temporality are rate, increase and irate. So those functions produce the semantically expected results regardless of whether the underlying data is cumulative or delta, as long as the temporality is set correctly.
In ES|QL you cannot use any of those functions on histograms. Instead, ES|QL will automatically use an inner, per-series aggregation which merges the histograms taking the temporality into account.
This is equivalent to how increase works for native histograms in PromQL. For example, the following two queries are equivalent:
ES|QL:
TS my-metrics
| STATS PERCENTILE(request_duration, 80) BY endpoint, TBUCKET(1m)
Note that in ES|QL you must use the TS command. If you use FROM, the temporality will be ignored.
PromQL:
histogram_quantile(0.8, sum by (endpoint) (increase(request_duration[1m])))
Downsampling also respects the temporality field. Because the temporality field is a dimension, cumulative and delta data points are always in separate time series and are downsampled independently.
For details on how each metric type is downsampled, refer to downsampling methods.