Browse Source

Test downsampling of empty and missing labels (#95568)

Salvatore Campagna 2 years ago
parent
commit
086993c8ca

+ 131 - 0
x-pack/plugin/rollup/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/rollup/10_basic.yml

@@ -219,6 +219,77 @@ setup:
         body:
           index.blocks.write: true
 
+  - do:
+      indices.create:
+        index: test-empty-missing
+        body:
+          settings:
+            number_of_shards: 1
+            number_of_replicas: 0
+            index:
+              mode: time_series
+              routing_path: [ metricset, k8s.pod.uid ]
+              time_series:
+                start_time: 2021-04-28T00:00:00Z
+                end_time: 2021-04-29T00:00:00Z
+          mappings:
+            properties:
+              "@timestamp":
+                type: date
+              metricset:
+                type: keyword
+                time_series_dimension: true
+              k8s:
+                properties:
+                  pod:
+                    properties:
+                      uid:
+                        type: keyword
+                        time_series_dimension: true
+                      name:
+                        type: keyword
+                      value:
+                        type: integer
+                        time_series_metric: gauge
+                      label:
+                        type: keyword
+
+  - do:
+      bulk:
+        refresh: true
+        index: test-empty-missing
+        body:
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:55:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "value": 10 }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "value": 20, "label": null, "unmapped": null }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:45:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "value": 30, "label": "abc", "unmapped": "abc"  }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:40:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "value": 40, "label": "xyz", "unmapped": "xyz" }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:55:20.467Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "value": 10 }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:50:20.467Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "value": 20, "label": null, "unmapped": null }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:45:20.467Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "value": 30, "label": "xyz", "unmapped": "xyz" }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:40:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "value": 40, "label": "abc", "unmapped": "abc" }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:55:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e9597ab", "value": 10 }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e9597ab", "value": 20, "label": null, "unmapped": null }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:45:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e9597ab", "value": 30, "label": null  }}}'
+          - '{"index": {}}'
+          - '{"@timestamp": "2021-04-28T18:40:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e9597ab", "value": 40, "unmapped": null }}}'
+
+  - do:
+      indices.put_settings:
+        index: test-empty-missing
+        body:
+          index.blocks.write: true
+
 ---
 "Downsample index":
   - skip:
@@ -1232,3 +1303,63 @@ setup:
   - match: { hits.hits.3._source.k8s.pod.value.sum: 42.0 }
   - match: { hits.hits.3._source.k8s.pod.agent.id: "second" }
   - match: { hits.hits.3._source.k8s.pod.agent.version: "2.1.7" }
+
+---
+"Downsample empty and missing labels":
+  - skip:
+      version: " - 8.6.99"
+      reason: "Downsampling GA-ed in 8.7.0"
+
+  - do:
+      indices.downsample:
+        index: test-empty-missing
+        target_index: rollup-test-empty-missing
+        body:  >
+          {
+            "fixed_interval": "1h"
+          }
+  - is_true: acknowledged
+
+  - do:
+      search:
+        index: rollup-test-empty-missing
+        body:
+          sort: [ "_tsid", "@timestamp" ]
+
+  - length: { hits.hits: 3 }
+
+  - match: { hits.hits.0._source._doc_count: 4 }
+  - match: { hits.hits.0._source.k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e959507 }
+  - match: { hits.hits.0._source.metricset: pod }
+  - match: { hits.hits.0._source.@timestamp: "2021-04-28T18:00:00.000Z" }
+  - match: { hits.hits.0._source.k8s.pod.name: "cat" }
+  - match: { hits.hits.0._source.k8s.pod.value.min: 10.0 }
+  - match: { hits.hits.0._source.k8s.pod.value.max: 40.0 }
+  - match: { hits.hits.0._source.k8s.pod.value.sum: 100.0 }
+  - match: { hits.hits.0._source.k8s.pod.value.value_count: 4 }
+  - match: { hits.hits.0._source.k8s.pod.label: "abc" }
+  - match: { hits.hits.0._source.k8s.pod.unmapped: "abc" }
+
+  - match: { hits.hits.1._source._doc_count: 4 }
+  - match: { hits.hits.1._source.k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e9597ab }
+  - match: { hits.hits.1._source.metricset: pod }
+  - match: { hits.hits.1._source.@timestamp: "2021-04-28T18:00:00.000Z" }
+  - match: { hits.hits.1._source.k8s.pod.name: "cat" }
+  - match: { hits.hits.1._source.k8s.pod.value.min: 10.0 }
+  - match: { hits.hits.1._source.k8s.pod.value.max: 40.0 }
+  - match: { hits.hits.1._source.k8s.pod.value.sum: 100.0 }
+  - match: { hits.hits.1._source.k8s.pod.value.value_count: 4 }
+  - match: { hits.hits.1._source.k8s.pod.label: null }
+  - match: { hits.hits.1._source.k8s.pod.unmapped: null }
+
+  - match: { hits.hits.2._source._doc_count: 4 }
+  - match: { hits.hits.2._source.k8s.pod.uid: df3145b3-0563-4d3b-a0f7-897eb2876ea9 }
+  - match: { hits.hits.2._source.metricset: pod }
+  - match: { hits.hits.2._source.@timestamp: "2021-04-28T18:00:00.000Z" }
+  - match: { hits.hits.2._source.k8s.pod.name: "dog" }
+  - match: { hits.hits.2._source.k8s.pod.value.min: 10.0 }
+  - match: { hits.hits.2._source.k8s.pod.value.max: 40.0 }
+  - match: { hits.hits.2._source.k8s.pod.value.sum: 100.0 }
+  - match: { hits.hits.2._source.k8s.pod.value.value_count: 4 }
+  - match: { hits.hits.2._source.k8s.pod.label: "xyz" }
+  - match: { hits.hits.2._source.k8s.pod.unmapped: "xyz" }