Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSDB: Add _tsid field to time_series indices #80276

Merged
merged 47 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2119b6d
Initial commit
csoulios Nov 3, 2021
9461331
Checkstyle
csoulios Nov 3, 2021
2ab1ff5
Merge branch 'master' into tsid-gen
csoulios Nov 3, 2021
fff4d7e
Removed TimeSeriesIdGeneratorService class
csoulios Nov 3, 2021
ca6c86e
Cleanup
csoulios Nov 3, 2021
12d89cf
Merge branch 'master' into tsid-gen
csoulios Nov 3, 2021
681831f
Revert
csoulios Nov 3, 2021
8267f74
Remove check for dynamic mapping update
csoulios Nov 3, 2021
7fbedc8
Return a shared instance of the tsid field mapper
csoulios Nov 3, 2021
1b5ef49
Remove tsid generator from Mapping class
csoulios Nov 4, 2021
95278e4
Remove TimeSeriesIdGenerator class
csoulios Nov 4, 2021
505d42b
Merge branch 'master' into tsid-gen
csoulios Nov 8, 2021
3ecaa8e
Merge branch 'master' into tsid-gen
csoulios Nov 9, 2021
e62254d
Delegate tsid generation to TsidFieldMapper
csoulios Nov 9, 2021
2975b48
Simplified dimension fields
csoulios Nov 9, 2021
7587518
More cleanup
csoulios Nov 9, 2021
b6f3f94
More cleanup
csoulios Nov 9, 2021
68e1526
Cleanup exception handling when parsing _tsid
csoulios Nov 9, 2021
a125aab
Fix broken tests
csoulios Nov 10, 2021
07ed667
Merge branch 'master' into tsid-gen
csoulios Nov 10, 2021
bc43ba0
Added more tests
csoulios Nov 10, 2021
5302edb
More tests
csoulios Nov 10, 2021
6860f38
More tests
csoulios Nov 10, 2021
05ed0d7
Cleanup
csoulios Nov 10, 2021
1a7e308
Merge branch 'master' into tsid-gen
csoulios Nov 11, 2021
8272182
Added rest tests for _tsid
csoulios Nov 11, 2021
05fc921
Merge branch 'master' into tsid-gen
csoulios Nov 11, 2021
15334e0
Sort by _tsid, @timestamp
csoulios Nov 11, 2021
5aaf469
Catch IOException at tsid field mapper level
csoulios Nov 11, 2021
9474774
spotless apply
csoulios Nov 11, 2021
359a22c
Fix test
csoulios Nov 13, 2021
02c2091
Fix test
csoulios Nov 13, 2021
14c23fe
Fix test
csoulios Nov 13, 2021
287a4c8
Merge branch 'master' into tsid-gen
csoulios Nov 13, 2021
7b87a71
Fix tests
csoulios Nov 15, 2021
271c66a
Merge branch 'master' into tsid-gen
csoulios Nov 15, 2021
1c1f0f8
Fix tests
csoulios Nov 15, 2021
713041d
Add _tsid field mapper only to time_series indices
csoulios Nov 16, 2021
c1cf213
Merge branch 'master' into tsid-gen
csoulios Nov 23, 2021
6a8dca6
Fix conflicts
csoulios Nov 23, 2021
5106a6e
Delegated building of tsid field mapper creation
csoulios Nov 23, 2021
0e10639
Fix brojen test
csoulios Nov 23, 2021
6d7d4ae
Merge branch 'master' into tsid-gen
csoulios Nov 23, 2021
91c91db
Fix broken tests
csoulios Nov 23, 2021
709700b
Addressed reviewer comments
csoulios Nov 25, 2021
1453e63
Merge branch 'master' into tsid-gen
csoulios Nov 25, 2021
12e5105
Merge branch 'master' into tsid-gen
csoulios Nov 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public void testNewReplicas() throws Exception {
}

public void testSearchTimeSeriesMode() throws Exception {
assumeTrue("time series mode introduced in 8.0.0", getOldClusterVersion().onOrAfter(Version.V_8_0_0));
assumeTrue("time series index sort by _tsid introduced in 8.1.0", getOldClusterVersion().onOrAfter(Version.V_8_1_0));
int numDocs;
if (isRunningAgainstOldCluster()) {
numDocs = createTimeSeriesModeIndex(1);
Expand Down Expand Up @@ -267,7 +267,7 @@ public void testSearchTimeSeriesMode() throws Exception {
}

public void testNewReplicasTimeSeriesMode() throws Exception {
assumeTrue("time series mode introduced in 8.0.0", getOldClusterVersion().onOrAfter(Version.V_8_0_0));
assumeTrue("time series index sort by _tsid introduced in 8.1.0", getOldClusterVersion().onOrAfter(Version.V_8_1_0));
if (isRunningAgainstOldCluster()) {
createTimeSeriesModeIndex(0);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private void bulk(String index, String valueSuffix, int count) throws IOExceptio
}

public void testTsdb() throws IOException {
assumeTrue("tsdb added in 8.0.0", UPGRADE_FROM_VERSION.onOrAfter(Version.V_8_0_0));
assumeTrue("sort by _tsid added in 8.1.0", UPGRADE_FROM_VERSION.onOrAfter(Version.V_8_1_0));
csoulios marked this conversation as resolved.
Show resolved Hide resolved

StringBuilder bulk = new StringBuilder();
switch (CLUSTER_TYPE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,39 @@ can't shadow metrics:
runtime_mappings:
deep.deeper.deepest:
type: keyword

---
# Test that _tsid field is not added if an index is not a time-series index
no _tsid in standard indices:
- skip:
version: " - 8.00.99"
reason: _tsid support introduced in 8.1.0

- do:
indices.create:
index: test
body:
settings:
index:
number_of_replicas: 0
number_of_shards: 2
mappings:
properties:
"@timestamp":
type: date
metricset:
type: keyword
time_series_dimension: true

- do:
field_caps:
index: test
fields: [metricset, _tsid]

- match: {fields.metricset.keyword.searchable: true}
- match: {fields.metricset.keyword.aggregatable: true}
- match: {fields.metricset.keyword.time_series_dimension: true}
- is_false: fields.metricset.keyword.indices
- is_false: fields.metricset.keyword.non_searchable_indices
- is_false: fields.metricset.keyword.non_aggregatable_indices
- is_false: fields._tsid # _tsid metadata field must not exist in non-time-series indices
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ set start_time and end_time:
end_time: 1632625792000
mappings:
properties:
"@timestamp":
type: date
metricset:
type: keyword
time_series_dimension: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ runtime field matching routing path:
properties:
"@timestamp":
type: date
dim_kw:
type: "keyword"
time_series_dimension: true
dim:
type: object
dynamic: runtime
Expand All @@ -214,7 +217,7 @@ runtime field matching routing path:
index: test
body:
- '{"index": {}}'
- '{"@timestamp": "2021-04-28T18:50:04.467Z", "dim": {"foo": "a"}}'
- '{"@timestamp": "2021-04-28T18:50:04.467Z", "dim_kw": "dim", "dim": {"foo": "a"}}'
- match: {items.0.index.error.reason: "All fields that match routing_path must be keywords with [time_series_dimension: true] and without the [script] parameter. [dim.foo] was a runtime [keyword]."}

---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ teardown:
---
"Create a snapshot and then restore it":
- skip:
version: " - 7.99.99"
reason: introduced in 8.0.0
version: " - 8.00.99"
reason: _tsid support introduced in 8.1.0
features: ["allowed_warnings"]

# Create index
Expand Down Expand Up @@ -134,10 +134,13 @@ teardown:
search:
index: test_index
body:
fields:
- field: _tsid
query:
query_string:
query: '+@timestamp:"2021-04-28T18:51:04.467Z" +k8s.pod.name:cat'

- match: {hits.total.value: 1}
- match: {hits.hits.0._source.k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e959507}
# TODO assert the _tsid once we generate it
- match: {hits.hits.0.fields._tsid: [ { k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e959507, metricset: pod } ] }

Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,20 @@ query a metric:

- match: {hits.total.value: 1}

# TODO add test showing that quering _tsid fails
---
"query tsid fails":
- skip:
version: " - 8.00.99"
reason: _tsid support introduced in 8.1.0

- do:
catch: /\[_tsid\] is not searchable/
search:
index: test
body:
query:
term:
_tsid: wont't work

---
fetch a dimension:
Expand Down Expand Up @@ -151,7 +164,24 @@ fetch a tag:
- match: {hits.hits.0.fields.k8s\.pod\.ip: ['10.10.55.2']}
- is_false: hits.hits.0.fields._tsid # tsid isn't fetched by default

# TODO add test to fetch the tsid
---
"fetch the tsid":
- skip:
version: " - 8.00.99"
reason: _tsid support introduced in 8.1.0

- do:
search:
index: test
body:
fields:
- field: _tsid
query:
query_string:
query: '+@timestamp:"2021-04-28T18:51:04.467Z" +k8s.pod.name:cat'

- match: {hits.total.value: 1}
- match: {hits.hits.0.fields._tsid: [{k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e959507, metricset: pod}]}

---
aggregate a dimension:
Expand Down Expand Up @@ -229,23 +259,44 @@ aggregate a tag:
- match: {aggregations.ips.buckets.2.key: 10.10.55.3}
- match: {aggregations.ips.buckets.2.doc_count: 4}

---
"aggregate the tsid":
- skip:
version: " - 8.00.99"
reason: _tsid support introduced in 8.1.0

- do:
search:
index: test
body:
size: 0
aggs:
tsids:
terms:
field: _tsid
order:
_key: asc

# TODO add a test aggregating the _tsid
- match: {hits.total.value: 8}
- match: {aggregations.tsids.buckets.0.key: {k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e959507, metricset: pod}}
- match: {aggregations.tsids.buckets.0.doc_count: 4}
- match: {aggregations.tsids.buckets.1.key: {k8s.pod.uid: df3145b3-0563-4d3b-a0f7-897eb2876ea9, metricset: pod}}
- match: {aggregations.tsids.buckets.1.doc_count: 4}

---
field capabilities:
- skip:
version: " - 7.99.99"
reason: introduced in 8.0.0
version: " - 8.00.99"
reason: _tsid support introduced in 8.1.0

- do:
field_caps:
index: test
fields: [k8s.pod.uid, k8s.pod.network.rx, k8s.pod.ip, _tsid]
fields: [k8s.pod.uid, k8s.pod.network.rx, k8s.pod.ip, metricset, _tsid]

# TODO assert time_series_metric and time_series_dimension
- match: {fields.k8s\.pod\.uid.keyword.searchable: true}
- match: {fields.k8s\.pod\.uid.keyword.aggregatable: true}
- match: {fields.k8s\.pod\.uid.keyword.searchable: true}
- match: {fields.k8s\.pod\.uid.keyword.aggregatable: true}
- match: {fields.k8s\.pod\.uid.keyword.time_series_dimension: true}
- is_false: fields.k8s\.pod\.uid.keyword.indices
- is_false: fields.k8s\.pod\.uid.keyword.non_searchable_indices
- is_false: fields.k8s\.pod\.uid.keyword.non_aggregatable_indices
Expand All @@ -259,4 +310,15 @@ field capabilities:
- is_false: fields.k8s\.pod\.ip.ip.indices
- is_false: fields.k8s\.pod\.ip.ip.non_searchable_indices
- is_false: fields.k8s\.pod\.ip.ip.non_aggregatable_indices
# TODO assert tsid once we build it:
- match: {fields.metricset.keyword.searchable: true}
- match: {fields.metricset.keyword.aggregatable: true}
- match: {fields.metricset.keyword.time_series_dimension: true}
- is_false: fields.metricset.keyword.indices
- is_false: fields.metricset.keyword.non_searchable_indices
- is_false: fields.metricset.keyword.non_aggregatable_indices
- match: {fields._tsid._tsid.metadata_field: true}
- match: {fields._tsid._tsid.searchable: false}
- match: {fields._tsid._tsid.aggregatable: true}
- is_false: fields._tsid._tsid.indices
- is_false: fields._tsid._tsid.non_searchable_indices
- is_false: fields._tsid._tsid.non_aggregatable_indices
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,40 @@ setup:
- '{"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}}}}'

# TODO search on _tsid in an alias
---
search an alias:
- skip:
version: " - 8.00.99"
reason: _tsid support introduced in 8.1.0

- do:
indices.put_alias:
index: test
name: test_alias

- do:
search:
index: test_alias
body:
size: 0
aggs:
tsids:
terms:
field: _tsid
order:
_key: asc

- match: {hits.total.value: 8}
- match: {aggregations.tsids.buckets.0.key: {k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e959507, metricset: pod}}
- match: {aggregations.tsids.buckets.0.doc_count: 4}
- match: {aggregations.tsids.buckets.1.key: {k8s.pod.uid: df3145b3-0563-4d3b-a0f7-897eb2876ea9, metricset: pod}}
- match: {aggregations.tsids.buckets.1.doc_count: 4}

---
index into alias:
- skip:
version: " - 7.99.99"
reason: introduced in 8.0.0
version: " - 8.00.99"
reason: _tsid support introduced in 8.1.0

- do:
indices.put_alias:
Expand All @@ -85,4 +112,23 @@ index into alias:
- '{"@timestamp": "2021-04-28T18:51:03.142Z", "metricset": "pod", "k8s": {"pod": {"name": "cow", "uid":"1c4fc7b8-93b7-4ba8-b609-2a48af2f8e39", "ip": "10.10.55.4", "network": {"tx": 1434595272, "rx": 530605511}}}}'
- match: {errors: false}

# TODO search on tsid once we generate it
- do:
search:
index: test
body:
size: 0
aggs:
tsids:
terms:
field: _tsid
order:
_key: asc

- match: {hits.total.value: 12}
- match: {aggregations.tsids.buckets.0.key: {k8s.pod.uid: 1c4fc7b8-93b7-4ba8-b609-2a48af2f8e39, metricset: pod}}
- match: {aggregations.tsids.buckets.0.doc_count: 4}
- match: {aggregations.tsids.buckets.1.key: {k8s.pod.uid: 947e4ced-1786-4e53-9e0c-5c447e959507, metricset: pod}}
- match: {aggregations.tsids.buckets.1.doc_count: 4}
- match: {aggregations.tsids.buckets.2.key: {k8s.pod.uid: df3145b3-0563-4d3b-a0f7-897eb2876ea9, metricset: pod}}
- match: {aggregations.tsids.buckets.2.doc_count: 4}

Loading