Skip to content

Commit 4f80f1f

Browse files
authored
Add new sampling method to the downsample API (#5563)
1 parent 9bd939c commit 4f80f1f

File tree

7 files changed

+96
-53
lines changed

7 files changed

+96
-53
lines changed

output/openapi/elasticsearch-openapi.json

Lines changed: 34 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/openapi/elasticsearch-serverless-openapi.json

Lines changed: 2 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema.json

Lines changed: 37 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/typescript/types.ts

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/indices/_types/Downsample.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,13 @@ export class DownsampleConfig {
2424
* The interval at which to aggregate the original time series index.
2525
*/
2626
fixed_interval: DurationLarge
27+
/**
28+
* The sampling method used to reduce the documents; it can be either `aggregate` or `last_value`. Defaults to `aggregate`.
29+
*/
30+
sampling_method?: SamplingMethod
31+
}
32+
33+
enum SamplingMethod {
34+
aggregate,
35+
last_value
2736
}

specification/indices/_types/DownsamplingRound.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,15 @@
1717
* under the License.
1818
*/
1919

20-
import { Duration } from '@_types/Time'
21-
import { DownsampleConfig } from '@indices/_types/Downsample'
20+
import { Duration, DurationLarge } from '@_types/Time'
2221

2322
export class DownsamplingRound {
2423
/**
2524
* The duration since rollover when this downsampling round should execute
2625
*/
2726
after: Duration
2827
/**
29-
* The downsample configuration to execute.
28+
* The downsample interval.
3029
*/
31-
config: DownsampleConfig
30+
fixed_interval: DurationLarge
3231
}

specification/indices/downsample/Request.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ import { DownsampleConfig } from '@indices/_types/Downsample'
2323

2424
/**
2525
* Downsample an index.
26-
* Aggregate a time series (TSDS) index and store pre-computed statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`) for each metric field grouped by a configured time interval.
26+
* Downsamples a time series (TSDS) index and reduces its size by keeping the last value or by pre-aggregating metrics:
27+
*
28+
* - When running in `aggregate` mode, it pre-calculates and stores statistical summaries (`min`, `max`, `sum`, `value_count` and `avg`)
29+
* for each metric field grouped by a configured time interval and their dimensions.
30+
* - When running in `last_value` mode, it keeps the last value for each metric in the configured interval and their dimensions.
31+
*
2732
* For example, a TSDS index that contains metrics sampled every 10 seconds can be downsampled to an hourly index.
2833
* All documents within an hour interval are summarized and stored as a single document in the downsample index.
2934
*
3035
* NOTE: Only indices in a time series data stream are supported.
3136
* Neither field nor document level security can be defined on the source index.
32-
* The source index must be read only (`index.blocks.write: true`).
37+
* The source index must be read-only (`index.blocks.write: true`).
3338
* @doc_id indices-downsample-data-stream
3439
* @rest_spec_name indices.downsample
3540
* @availability stack since=8.5.0 stability=experimental

0 commit comments

Comments
 (0)