-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TSDB: Add support for composite aggregation on
_tsid
field (#81998)
Currently, composite aggregation supports only string or numeric values for the fields in the sources part of the composite aggregation. Although _tsid is encoded and stored as a byte array, it is formatted as map {"dim1": "value1", "dim2": value2", ...} for input/output. This PR adds support for composite aggregation on _tsid field. Relates to #74660
- Loading branch information
Showing
12 changed files
with
411 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/100_composite.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
setup: | ||
- skip: | ||
version: " - 8.0.99" | ||
reason: introduced in 8.1.0 | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
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 | ||
ip: | ||
type: ip | ||
network: | ||
properties: | ||
tx: | ||
type: long | ||
rx: | ||
type: long | ||
- do: | ||
bulk: | ||
refresh: true | ||
index: test | ||
body: | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2001818691, "rx": 802133794}}}}' | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:24.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2005177954, "rx": 801479970}}}}' | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:44.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.1", "network": {"tx": 2006223737, "rx": 802337279}}}}' | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:51:04.467Z", "metricset": "pod", "k8s": {"pod": {"name": "cat", "uid":"947e4ced-1786-4e53-9e0c-5c447e959507", "ip": "10.10.55.2", "network": {"tx": 2012916202, "rx": 803685721}}}}' | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434521831, "rx": 530575198}}}}' | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:23.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434577921, "rx": 530600088}}}}' | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:53.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434587694, "rx": 530604797}}}}' | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:51:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "dog", "uid":"df3145b3-0563-4d3b-a0f7-897eb2876ea9", "ip": "10.10.55.3", "network": {"tx": 1434595272, "rx": 530605511}}}}' | ||
|
||
--- | ||
composite aggregation on tsid: | ||
- skip: | ||
version: " - 8.0.99" | ||
reason: _tsid introduced in 8.1.0 | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggregations: | ||
tsids: | ||
composite: | ||
sources: [ | ||
"tsid": { | ||
"terms": { | ||
"field": "_tsid" | ||
} | ||
}, | ||
"date": { | ||
"date_histogram": { | ||
"field": "@timestamp", | ||
"calendar_interval": "1m" | ||
} | ||
} | ||
] | ||
|
||
- match: { hits.total.value: 8 } | ||
- length: { aggregations.tsids.buckets: 4 } | ||
- match: { aggregations.tsids.buckets.0.key.tsid.k8s\.pod\.uid: "947e4ced-1786-4e53-9e0c-5c447e959507" } | ||
- match: { aggregations.tsids.buckets.0.key.tsid.metricset: "pod" } | ||
- match: { aggregations.tsids.buckets.0.key.date: 1619635800000} | ||
- match: { aggregations.tsids.buckets.0.doc_count: 3 } | ||
- match: { aggregations.tsids.buckets.1.key.tsid.k8s\.pod\.uid: "947e4ced-1786-4e53-9e0c-5c447e959507" } | ||
- match: { aggregations.tsids.buckets.1.key.tsid.metricset: "pod" } | ||
- match: { aggregations.tsids.buckets.1.key.date: 1619635860000} | ||
- match: { aggregations.tsids.buckets.1.doc_count: 1 } | ||
- match: { aggregations.tsids.buckets.2.key.tsid.k8s\.pod\.uid: "df3145b3-0563-4d3b-a0f7-897eb2876ea9" } | ||
- match: { aggregations.tsids.buckets.2.key.tsid.metricset: "pod" } | ||
- match: { aggregations.tsids.buckets.2.key.date: 1619635800000} | ||
- match: { aggregations.tsids.buckets.2.doc_count: 3 } | ||
- match: { aggregations.tsids.buckets.3.key.tsid.k8s\.pod\.uid: "df3145b3-0563-4d3b-a0f7-897eb2876ea9" } | ||
- match: { aggregations.tsids.buckets.3.key.tsid.metricset: "pod" } | ||
- match: { aggregations.tsids.buckets.3.key.date: 1619635860000} | ||
- match: { aggregations.tsids.buckets.3.doc_count: 1 } | ||
- match: { aggregations.tsids.after_key.tsid.k8s\.pod\.uid: "df3145b3-0563-4d3b-a0f7-897eb2876ea9" } | ||
- match: { aggregations.tsids.after_key.tsid.metricset: "pod" } | ||
- match: { aggregations.tsids.after_key.date: 1619635860000} | ||
|
||
--- | ||
composite aggregation on tsid with after: | ||
- skip: | ||
version: " - 8.0.99" | ||
reason: _tsid introduced in 8.1.0 | ||
|
||
- do: | ||
search: | ||
index: test | ||
body: | ||
size: 0 | ||
aggregations: | ||
tsids: | ||
composite: | ||
sources: [ | ||
"tsid": { | ||
"terms": { | ||
"field": "_tsid" | ||
} | ||
}, | ||
"date": { | ||
"date_histogram": { | ||
"field": "@timestamp", | ||
"calendar_interval": "1m" | ||
} | ||
} | ||
] | ||
after: { | ||
tsid: { k8s.pod.uid: "df3145b3-0563-4d3b-a0f7-897eb2876ea9", metricset: "pod" }, | ||
date: 1619635800000 | ||
} | ||
|
||
- match: { hits.total.value: 8 } | ||
- length: { aggregations.tsids.buckets: 1 } | ||
- match: { aggregations.tsids.buckets.0.key.tsid.k8s\.pod\.uid: "df3145b3-0563-4d3b-a0f7-897eb2876ea9" } | ||
- match: { aggregations.tsids.buckets.0.key.tsid.metricset: "pod" } | ||
- match: { aggregations.tsids.buckets.0.key.date: 1619635860000} | ||
- match: { aggregations.tsids.buckets.0.doc_count: 1 } | ||
- match: { aggregations.tsids.after_key.tsid.k8s\.pod\.uid: "df3145b3-0563-4d3b-a0f7-897eb2876ea9" } | ||
- match: { aggregations.tsids.after_key.tsid.metricset: "pod" } | ||
- match: { aggregations.tsids.after_key.date: 1619635860000} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.