|
@@ -205,3 +205,126 @@
|
|
|
- length: { aggregations.by_date.buckets: 2 }
|
|
|
- match: { aggregations.by_date.buckets.0.rate.value: 6.0 }
|
|
|
- match: { aggregations.by_date.buckets.1.rate.value: 18.0 }
|
|
|
+
|
|
|
+---
|
|
|
+"rate aggregation on counter field":
|
|
|
+ - skip:
|
|
|
+ version: " - 8.6.99"
|
|
|
+ reason: "counter field support added in 8.7"
|
|
|
+ features: close_to
|
|
|
+
|
|
|
+ - do:
|
|
|
+ indices.create:
|
|
|
+ index: test-rate
|
|
|
+ body:
|
|
|
+ settings:
|
|
|
+ index:
|
|
|
+ mode: time_series
|
|
|
+ routing_path: [ host ]
|
|
|
+ time_series:
|
|
|
+ start_time: 2021-04-28T00:00:00Z
|
|
|
+ end_time: 2021-04-29T00:00:00Z
|
|
|
+ mappings:
|
|
|
+ properties:
|
|
|
+ "@timestamp":
|
|
|
+ type: date
|
|
|
+ host:
|
|
|
+ type: keyword
|
|
|
+ time_series_dimension: true
|
|
|
+ bytes_gauge:
|
|
|
+ type : long
|
|
|
+ time_series_metric: gauge
|
|
|
+ bytes_counter:
|
|
|
+ type: long
|
|
|
+ time_series_metric: counter
|
|
|
+ byes:
|
|
|
+ type: long
|
|
|
+
|
|
|
+ - do:
|
|
|
+ bulk:
|
|
|
+ refresh: true
|
|
|
+ index: test-rate
|
|
|
+ body:
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:00.000Z", "host": "one", "bytes_counter": 1000, "bytes_gauge": 1000, "bytes": 1000 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:01.000Z", "host": "one", "bytes_counter": 1100, "bytes_gauge": 100, "bytes": 100 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:02.000Z", "host": "one", "bytes_counter": 1200, "bytes_gauge": 100, "bytes": 100 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:03.000Z", "host": "one", "bytes_counter": 1250, "bytes_gauge": 50, "bytes": 50 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:04.000Z", "host": "one", "bytes_counter": 1310, "bytes_gauge": 60, "bytes": 60 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:05.000Z", "host": "one", "bytes_counter": 1350, "bytes_gauge": 40, "bytes": 40 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:06.000Z", "host": "one", "bytes_counter": 1420, "bytes_gauge": 70, "bytes": 70 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:07.000Z", "host": "one", "bytes_counter": 1500, "bytes_gauge": 80, "bytes": 80 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:08.000Z", "host": "one", "bytes_counter": 1520, "bytes_gauge": 20, "bytes": 20 }'
|
|
|
+ - '{"index": {}}'
|
|
|
+ - '{"@timestamp": "2021-04-28T18:50:09.000Z", "host": "one", "bytes_counter": 1550, "bytes_gauge": 30, "bytes": 30 }'
|
|
|
+
|
|
|
+ - do:
|
|
|
+ search:
|
|
|
+ index: test-rate
|
|
|
+ body:
|
|
|
+ size: 0
|
|
|
+ query:
|
|
|
+ bool:
|
|
|
+ filter:
|
|
|
+ range:
|
|
|
+ "@timestamp":
|
|
|
+ gte: "2021-04-28T18:00:00.000Z"
|
|
|
+ lte: "2021-04-28T19:00:00.000Z"
|
|
|
+ aggs:
|
|
|
+ date_histogram:
|
|
|
+ date_histogram:
|
|
|
+ field: "@timestamp"
|
|
|
+ fixed_interval: 1m
|
|
|
+ time_zone: Europe/Ljubljana
|
|
|
+ min_doc_count: 1
|
|
|
+ aggs:
|
|
|
+ 8:
|
|
|
+ sum_bucket:
|
|
|
+ buckets_path: 8-bucket>8-metric
|
|
|
+ 9:
|
|
|
+ sum_bucket:
|
|
|
+ buckets_path: 9-bucket>9-metric
|
|
|
+ 10:
|
|
|
+ rate:
|
|
|
+ field: bytes_gauge
|
|
|
+ unit: second
|
|
|
+ 11:
|
|
|
+ rate:
|
|
|
+ field: bytes
|
|
|
+ unit: second
|
|
|
+ 8-bucket:
|
|
|
+ terms:
|
|
|
+ field: host
|
|
|
+ order:
|
|
|
+ _key: desc
|
|
|
+ size: 500
|
|
|
+ aggs:
|
|
|
+ 8-metric:
|
|
|
+ rate:
|
|
|
+ field: bytes_gauge
|
|
|
+ unit: second
|
|
|
+ 9-bucket:
|
|
|
+ time_series: { }
|
|
|
+ aggs:
|
|
|
+ 9-metric:
|
|
|
+ rate:
|
|
|
+ field: bytes_counter
|
|
|
+ unit: second
|
|
|
+
|
|
|
+ - match: { hits.total.value: 10 }
|
|
|
+ - length: { aggregations.date_histogram.buckets: 1 }
|
|
|
+ - match: { aggregations.date_histogram.buckets.0.key_as_string: "2021-04-28T20:50:00.000+02:00" }
|
|
|
+ - match: { aggregations.date_histogram.buckets.0.doc_count: 10 }
|
|
|
+ - close_to: { aggregations.date_histogram.buckets.0.11.value: { value: 25.83, error: 0.01 } }
|
|
|
+ - close_to: { aggregations.date_histogram.buckets.0.10.value: { value: 25.83, error: 0.01 } }
|
|
|
+ - close_to: { aggregations.date_histogram.buckets.0.8.value: { value: 25.83, error: 0.01 } }
|
|
|
+ # Rate aggregation on counters uses the actual bucket time interval instead of the parent date histogram calendar interval
|
|
|
+ - close_to: { aggregations.date_histogram.buckets.0.9.value: { value: 0.06, error: 0.01 } }
|