|
| 1 | +"Downsample index": |
| 2 | + - requires: |
| 3 | + cluster_features: ["gte_v8.13.0"] |
| 4 | + reason: _tsid hashing introduced in 8.13 |
| 5 | + |
| 6 | + - do: |
| 7 | + indices.create: |
| 8 | + index: test |
| 9 | + body: |
| 10 | + settings: |
| 11 | + number_of_shards: 1 |
| 12 | + index: |
| 13 | + mode: time_series |
| 14 | + routing_path: [sensor_id] |
| 15 | + time_series: |
| 16 | + start_time: 2021-04-28T00:00:00Z |
| 17 | + end_time: 2021-04-29T00:00:00Z |
| 18 | + mappings: |
| 19 | + properties: |
| 20 | + "@timestamp": |
| 21 | + type: date |
| 22 | + sensor_id: |
| 23 | + type: keyword |
| 24 | + time_series_dimension: true |
| 25 | + temperature: |
| 26 | + type: aggregate_metric_double |
| 27 | + metrics: [min, sum, value_count] |
| 28 | + default_metric: sum |
| 29 | + time_series_metric: gauge |
| 30 | + - do: |
| 31 | + bulk: |
| 32 | + refresh: true |
| 33 | + index: test |
| 34 | + body: |
| 35 | + - '{"index": {}}' |
| 36 | + - '{"@timestamp": "2021-04-28T18:00:0.000Z", "sensor_id": "1", "temperature": {"min": 24.7, "sum": 50.2, "value_count": 2}}' |
| 37 | + - '{"index": {}}' |
| 38 | + - '{"@timestamp": "2021-04-28T18:30:0.000Z", "sensor_id": "1", "temperature": {"min": 24.2, "sum": 73.8, "value_count": 3}}' |
| 39 | + - '{"index": {}}' |
| 40 | + - '{"@timestamp": "2021-04-28T19:00:0.000Z", "sensor_id": "1", "temperature": {"min": 25.1, "sum": 51.0, "value_count": 2}}' |
| 41 | + - '{"index": {}}' |
| 42 | + - '{"@timestamp": "2021-04-28T19:30:0.000Z", "sensor_id": "1", "temperature": {"min": 24.8, "sum": 24.8, "value_count": 1}}' |
| 43 | + - '{"index": {}}' |
| 44 | + - '{"@timestamp": "2021-04-28T20:00:0.000Z", "sensor_id": "1", "temperature": {"min": 24.6, "sum": 49.1, "value_count": 2}}' |
| 45 | + |
| 46 | + - do: |
| 47 | + indices.put_settings: |
| 48 | + index: test |
| 49 | + body: |
| 50 | + index.blocks.write: true |
| 51 | + |
| 52 | + - do: |
| 53 | + indices.downsample: |
| 54 | + index: test |
| 55 | + target_index: test-downsample |
| 56 | + body: > |
| 57 | + { |
| 58 | + "fixed_interval": "1h" |
| 59 | + } |
| 60 | + - is_true: acknowledged |
| 61 | + |
| 62 | + - do: |
| 63 | + indices.get_mapping: |
| 64 | + index: test-downsample |
| 65 | + - match: |
| 66 | + test-downsample.mappings.properties.temperature: |
| 67 | + type: aggregate_metric_double |
| 68 | + metrics: [min, sum, value_count] |
| 69 | + default_metric: sum |
| 70 | + time_series_metric: gauge |
0 commit comments