-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TSDB: Automatically add timestamp mapper (#79136)
If tsdb is enabled we need an `@timestamp` field. This automatically maps the field if it is missing and fails to create indices in time_series mode that map `@timestamp` as anything other than `date` and `date_nanos`.
- Loading branch information
Showing
17 changed files
with
410 additions
and
105 deletions.
There are no files selected for viewing
179 changes: 179 additions & 0 deletions
179
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/15_timestamp_mapping.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,179 @@ | ||
|
||
--- | ||
date: | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: introduced in 8.0.0 to be backported to 7.16.0 | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
index: | ||
mode: time_series | ||
routing_path: [metricset] | ||
number_of_replicas: 0 | ||
number_of_shards: 2 | ||
mappings: | ||
properties: | ||
"@timestamp": | ||
type: date | ||
metricset: | ||
type: keyword | ||
time_series_dimension: true | ||
|
||
- do: | ||
indices.get_mapping: | ||
index: test | ||
- match: { "[email protected]": date } | ||
- match: { 'test.mappings._data_stream_timestamp.enabled': true } | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
index: test_index | ||
body: | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod"}' | ||
|
||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
docvalue_fields: [ '@timestamp' ] | ||
- match: {hits.total.value: 1} | ||
- match: { "hits.hits.0.fields.@timestamp": ["2021-04-28T18:50:04.467Z"] } | ||
|
||
--- | ||
date_nanos: | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: introduced in 8.0.0 to be backported to 7.16.0 | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
index: | ||
mode: time_series | ||
routing_path: [metricset] | ||
number_of_replicas: 0 | ||
number_of_shards: 2 | ||
mappings: | ||
properties: | ||
"@timestamp": | ||
type: date_nanos | ||
metricset: | ||
type: keyword | ||
time_series_dimension: true | ||
|
||
- do: | ||
indices.get_mapping: | ||
index: test | ||
- match: { "[email protected]": date_nanos } | ||
- match: { 'test.mappings._data_stream_timestamp.enabled': true } | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
index: test_index | ||
body: | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod"}' | ||
|
||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
docvalue_fields: [ '@timestamp' ] | ||
- match: {hits.total.value: 1} | ||
- match: { "hits.hits.0.fields.@timestamp": ["2021-04-28T18:50:04.467Z"] } | ||
|
||
--- | ||
automatically add with date: | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: introduced in 8.0.0 to be backported to 7.16.0 | ||
|
||
- do: | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
index: | ||
mode: time_series | ||
routing_path: [metricset] | ||
number_of_replicas: 0 | ||
number_of_shards: 2 | ||
mappings: | ||
properties: | ||
metricset: | ||
type: keyword | ||
time_series_dimension: true | ||
|
||
- do: | ||
indices.get_mapping: | ||
index: test | ||
- match: { 'test.mappings.properties.@timestamp': { "type": date } } | ||
- match: { 'test.mappings._data_stream_timestamp.enabled': true } | ||
|
||
- do: | ||
bulk: | ||
refresh: true | ||
index: test_index | ||
body: | ||
- '{"index": {}}' | ||
- '{"@timestamp": "2021-04-28T18:50:04.467Z", "metricset": "pod"}' | ||
|
||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
docvalue_fields: [ '@timestamp' ] | ||
- match: {hits.total.value: 1} | ||
- match: { "hits.hits.0.fields.@timestamp": ["2021-04-28T18:50:04.467Z"] } | ||
|
||
--- | ||
reject @timestamp with wrong type: | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: introduced in 8.0.0 to be backported to 7.16.0 | ||
|
||
- do: | ||
catch: /data stream timestamp field \[@timestamp\] is of type \[keyword\], but \[date,date_nanos\] is expected/ | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
index: | ||
mode: time_series | ||
routing_path: [metricset] | ||
number_of_replicas: 0 | ||
number_of_shards: 2 | ||
mappings: | ||
properties: | ||
"@timestamp": | ||
type: keyword | ||
|
||
--- | ||
reject timestamp meta field with wrong type: | ||
- skip: | ||
version: " - 7.99.99" | ||
reason: introduced in 8.0.0 to be backported to 7.16.0 | ||
|
||
- do: | ||
catch: /.* time series index \[_data_stream_timestamp\] meta field must be enabled/ | ||
indices.create: | ||
index: test | ||
body: | ||
settings: | ||
index: | ||
mode: time_series | ||
routing_path: [metricset] | ||
number_of_replicas: 0 | ||
number_of_shards: 2 | ||
mappings: | ||
_data_stream_timestamp: | ||
enabled: false |
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.