Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions manage-data/data-store/data-streams/downsampling-concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ In a time series data stream, a single document is created for each timestamp. T
:alt: time series metric anatomy
:::

For the most current data, the metrics series typically has a low sampling time interval, to optimize for queries that require a high data resolution.
For the most current data, the metrics series typically has a low sampling time interval to optimize for queries that require a high data resolution.

:::{image} /manage-data/images/elasticsearch-reference-time-series-original.png
:alt: time series original
Expand All @@ -51,15 +51,7 @@ Downsampling is applied to the individual backing indices of the TSDS. The downs
For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index. All documents within a given hour interval are summarized and stored as a single document in the downsampled index.

2. For each new document, copies all [time series dimensions](time-series-data-stream-tsds.md#time-series-dimension) from the source index to the target index. Dimensions in a TSDS are constant, so this step happens only once per bucket.
3. For each [time series metric](time-series-data-stream-tsds.md#time-series-metric) field, computes aggregations for all documents in the bucket.

* `gauge` field type:
* `min`, `max`, `sum`, and `value_count` are stored as type `aggregate_metric_double`.
* `counter` field type:
* the last value is stored and the type is preserved.
* `histogram` field type: {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview`
* individual histograms are merged into a single histogram that is stored, preserving the type. The `histogram` field type uses the [T-Digest](elasticsearch://reference/aggregations/search-aggregations-metrics-percentile-aggregation.md) algorithm.

3. For each [time series metric](time-series-data-stream-tsds.md#time-series-metric) field, it computes the downsampled values based on the [downsampling method](#downsampling-methods).
4. For all other fields, copies the most recent value to the target index.
5. Replaces the original index with the downsampled index, then deletes the original index.

Expand All @@ -71,6 +63,26 @@ You can downsample a downsampled index. The subsequent downsampling interval mus

% TODO ^^ consider mini table in step 3; refactor generally

### Downsampling methods [downsampling-methods]

The downsampling method is the technique used to reduce multiple values within the same bucket into a single representative value. Two distinct methods exist:

* `last_value`: {applies_to}`stack: preview 9.3` {applies_to}`serverless: ga`
This method increases the sampling interval by storing only the most recent value for each metric in the same bucket. While this reduces data accuracy, it offers the benefit of conserving storage space. It applies to all metric types.

* `aggregate`:
This method preserves data accuracy by computing and storing statistical aggregations for all documents within the bucket, though it requires more storage space. It applies to each metric type in the following way:
* `gauge` field type:
* `min`, `max`, `sum`, and `value_count` are stored as type `aggregate_metric_double`.
* `counter` field type:
* the last value is stored and the type is preserved.
* `histogram` field type: {applies_to}`stack: preview 9.3` {applies_to}`serverless: preview`
* individual histograms are merged into a single histogram that is stored, preserving the type. The `histogram` field type uses the [T-Digest](elasticsearch://reference/aggregations/search-aggregations-metrics-percentile-aggregation.md) algorithm.

:::{tip}
When downsampling a downsampled index, use the same downsampling method as the source index.
:::

### Source and target index field mappings [downsample-api-mappings]

Fields in the target downsampled index are created with the same mapping as in the source index, with one exception: `time_series_metric: gauge` fields are changed to `aggregate_metric_double`.
Expand Down
11 changes: 8 additions & 3 deletions manage-data/data-store/data-streams/run-downsampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@

* Set `fixed_interval` to your preferred level of granularity. The original time series data will be aggregated at this interval.
* Set `after` to the minimum time to wait after an index rollover, before running downsampling.
* {applies_to}`stack: preview 9.3` {applies_to}`serverless: ga` (Optional) Set `downsampling_method` to your preferred [downsampling method](/manage-data/data-store/data-streams/downsampling-concepts.md#downsampling-methods), or leave it unspecified to use the default method (`aggregate`).

```console
PUT _data_stream/my-data-stream/_lifecycle
{
"data_retention": "7d",
"downsampling_method": "aggregate",
"downsampling": [
{
"after": "1m",
Expand Down Expand Up @@ -81,23 +83,26 @@
"max_age": "5m"
},
"downsample": {
"fixed_interval": "5m"
"fixed_interval": "5m",
"sampling_method": "aggregate"
}
}
},
"warm": {
"actions": {
"downsample": {
"fixed_interval": "1h"
"fixed_interval": "1h",
"sampling_method": "aggregate"
}
}
}
}
}
}
```
Set `fixed_interval` to your preferred level of granularity. The original time series data will be aggregated at this interval. The downsample action runs after the index is rolled over and the [index time series end time](elasticsearch://reference/elasticsearch/index-settings/time-series.md#index-time-series-end-time) has passed.

* Set `fixed_interval` to your preferred level of granularity. The original time series data will be aggregated at this interval. The downsample action runs after the index is rolled over and the [index time series end time](elasticsearch://reference/elasticsearch/index-settings/time-series.md#index-time-series-end-time) has passed.

Check notice on line 104 in manage-data/data-store/data-streams/run-downsampling.md

View workflow job for this annotation

GitHub Actions / preview / vale

Elastic.FutureTense: 'will be' might be in future tense. Write in the present tense to describe the state of the product as it is now.
* {applies_to}`stack: preview 9.3` (Optional) Set `sampling_method` to your preferred [downsampling method](/manage-data/data-store/data-streams/downsampling-concepts.md#downsampling-methods), or leave it unspecified to use the default method (`aggregate`).

:::
::::
Expand Down
Loading