Skip to content

Fix the timestamp field of a data stream to @timestamp #59076

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

Merged
merged 16 commits into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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 @@ -86,7 +86,7 @@ private static ComposableIndexTemplate randomIndexTemplate() {
Long priority = randomBoolean() ? null : randomNonNegativeLong();
Long version = randomBoolean() ? null : randomNonNegativeLong();
if (randomBoolean()) {
dataStreamTemplate = new ComposableIndexTemplate.DataStreamTemplate(randomAlphaOfLength(8));
dataStreamTemplate = new ComposableIndexTemplate.DataStreamTemplate("@timestamp");
}
return new ComposableIndexTemplate(patterns, randomTemplate(), composedOf, priority, version, meta, dataStreamTemplate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private static DataStream randomInstance() {
long generation = indices.size() + randomLongBetween(1, 128);
String dataStreamName = randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
indices.add(new Index(getDefaultBackingIndexName(dataStreamName, generation), UUIDs.randomBase64UUID(random())));
return new DataStream(dataStreamName, createTimestampField(randomAlphaOfLength(10)), indices, generation);
return new DataStream(dataStreamName, createTimestampField("@timestamp"), indices, generation);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ setup:
body:
index_patterns: logs-*
data_stream:
timestamp_field: timestamp
timestamp_field: '@timestamp'
template:
mappings:
properties:
timestamp:
'@timestamp':
type: date

---
Expand All @@ -36,7 +36,7 @@ teardown:
refresh: true
body:
foo: bar
timestamp: '2020-12-12'
'@timestamp': '2020-12-12'

- do:
reindex:
Expand Down Expand Up @@ -69,7 +69,7 @@ teardown:
refresh: true
body:
foo: bar
timestamp: '2020-12-12'
'@timestamp': '2020-12-12'

- do:
reindex:
Expand Down Expand Up @@ -102,7 +102,7 @@ teardown:
refresh: true
body:
foo: bar
timestamp: '2020-12-12'
'@timestamp': '2020-12-12'

- do:
reindex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
- match: {data_streams.1.name: my_remote_cluster:simple-data-stream2}
- match: {data_streams.1.backing_indices.0: .ds-simple-data-stream2-000001}
- match: {data_streams.1.backing_indices.1: .ds-simple-data-stream2-000002}
- match: {data_streams.1.timestamp_field: "@timestamp2"}
- match: {data_streams.1.timestamp_field: "@timestamp"}
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
template:
mappings:
properties:
'@timestamp2':
'@timestamp':
type: date
data_stream:
timestamp_field: '@timestamp2'
timestamp_field: '@timestamp'

- do:
indices.create_data_stream:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ setup:
template:
mappings:
properties:
'@timestamp2':
'@timestamp':
type: date
data_stream:
timestamp_field: '@timestamp2'
timestamp_field: '@timestamp'

---
"Create data stream":
Expand All @@ -55,7 +55,7 @@ setup:
- length: { 0.indices: 1 }
- match: { 0.indices.0.index_name: '.ds-simple-data-stream1-000001' }
- match: { 1.name: simple-data-stream2 }
- match: { 1.timestamp_field.name: '@timestamp2' }
- match: { 1.timestamp_field.name: '@timestamp' }
- match: { 0.generation: 1 }
- length: { 1.indices: 1 }
- match: { 1.indices.0.index_name: '.ds-simple-data-stream2-000001' }
Expand Down Expand Up @@ -124,31 +124,26 @@ setup:
indices.get_data_stream: {}
- match: { 0.name: simple-data-stream1 }
- match: { 0.timestamp_field.name: '@timestamp' }
- match: { 0.timestamp_field.mapping: {type: date} }
- match: { 0.generation: 1 }
- match: { 1.name: simple-data-stream2 }
- match: { 1.timestamp_field.name: '@timestamp2' }
- match: { 1.timestamp_field.mapping: {type: date} }
- match: { 1.timestamp_field.name: '@timestamp' }
- match: { 1.generation: 1 }

- do:
indices.get_data_stream:
name: simple-data-stream1
- match: { 0.name: simple-data-stream1 }
- match: { 0.timestamp_field.name: '@timestamp' }
- match: { 0.timestamp_field.mapping: {type: date} }
- match: { 0.generation: 1 }

- do:
indices.get_data_stream:
name: simple-data-stream*
- match: { 0.name: simple-data-stream1 }
- match: { 0.timestamp_field.name: '@timestamp' }
- match: { 0.timestamp_field.mapping: {type: date} }
- match: { 0.generation: 1 }
- match: { 1.name: simple-data-stream2 }
- match: { 1.timestamp_field.name: '@timestamp2' }
- match: { 1.timestamp_field.mapping: {type: date} }
- match: { 1.timestamp_field.name: '@timestamp' }
- match: { 1.generation: 1 }

- do:
Expand Down Expand Up @@ -235,35 +230,35 @@ setup:
template:
mappings:
properties:
'timestamp':
'@timestamp':
type: date
data_stream:
timestamp_field: timestamp
timestamp_field: '@timestamp'

- do:
index:
index: logs-foobar
body: { timestamp: '2020-12-12' }
body: { '@timestamp': '2020-12-12' }
- match: { _index: .ds-logs-foobar-000001 }

- do:
catch: bad_request
index:
index: .ds-logs-foobar-000001
body: { timestamp: '2020-12-12' }
body: { '@timestamp': '2020-12-12' }

- do:
bulk:
body:
- create:
_index: .ds-logs-foobar-000001
- timestamp: '2020-12-12'
- '@timestamp': '2020-12-12'
- index:
_index: .ds-logs-foobar-000001
- timestamp: '2020-12-12'
- '@timestamp': '2020-12-12'
- create:
_index: logs-foobar
- timestamp: '2020-12-12'
- '@timestamp': '2020-12-12'
- match: { errors: true }
- match: { items.0.create.status: 400 }
- match: { items.0.create.error.type: illegal_argument_exception }
Expand Down Expand Up @@ -296,10 +291,10 @@ setup:
template:
mappings:
properties:
'timestamp':
'@timestamp':
type: date
data_stream:
timestamp_field: timestamp
timestamp_field: '@timestamp'

- do:
catch: bad_request
Expand All @@ -315,19 +310,19 @@ setup:
- foo: bar
- create:
_index: logs-foobar
- timestamp: '2020-12-12'
- '@timestamp': '2020-12-12'
- create:
_index: logs-foobar
- timestamp: ['2020-12-12', '2022-12-12']
- '@timestamp': ['2020-12-12', '2022-12-12']
- match: { errors: true }
- match: { items.0.create.status: 400 }
- match: { items.0.create.error.caused_by.type: illegal_argument_exception }
- match: { items.0.create.error.caused_by.reason: "data stream timestamp field [timestamp] is missing" }
- match: { items.0.create.error.caused_by.reason: "data stream timestamp field [@timestamp] is missing" }
- match: { items.1.create.result: created }
- match: { items.1.create._index: .ds-logs-foobar-000001 }
- match: { items.2.create.status: 400 }
- match: { items.2.create.error.caused_by.type: illegal_argument_exception }
- match: { items.2.create.error.caused_by.reason: "data stream timestamp field [timestamp] encountered multiple values" }
- match: { items.2.create.error.caused_by.reason: "data stream timestamp field [@timestamp] encountered multiple values" }

- do:
indices.delete_data_stream:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@
body:
index_patterns: logs-*
data_stream:
timestamp_field: timestamp
timestamp_field: '@timestamp'
template:
settings:
number_of_shards: 1
number_of_replicas: 0
mappings:
properties:
timestamp:
'@timestamp':
type: date

- do:
index:
index: logs-foobar
refresh: true
body:
'timestamp': '2020-12-12'
'@timestamp': '2020-12-12'
foo: bar

- do:
Expand All @@ -43,7 +43,7 @@
indices.get_data_stream:
name: logs-foobar
- match: { 0.name: logs-foobar }
- match: { 0.timestamp_field.name: 'timestamp' }
- match: { 0.timestamp_field.name: '@timestamp' }
- length: { 0.indices: 1 }
- match: { 0.indices.0.index_name: '.ds-logs-foobar-000001' }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ setup:
- match: {data_streams.1.name: simple-data-stream2}
- match: {data_streams.1.backing_indices.0: .ds-simple-data-stream2-000001}
- match: {data_streams.1.backing_indices.1: .ds-simple-data-stream2-000002}
- match: {data_streams.1.timestamp_field: "@timestamp2"}
- match: {data_streams.1.timestamp_field: "@timestamp"}

- do:
indices.delete_data_stream:
Expand Down Expand Up @@ -165,7 +165,7 @@ setup:
- match: {data_streams.1.name: simple-data-stream2}
- match: {data_streams.1.backing_indices.0: .ds-simple-data-stream2-000001}
- match: {data_streams.1.backing_indices.1: .ds-simple-data-stream2-000002}
- match: {data_streams.1.timestamp_field: "@timestamp2"}
- match: {data_streams.1.timestamp_field: "@timestamp"}

- do:
indices.delete_data_stream:
Expand Down
Loading