Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8f6c5da
Default to @timestamp in composable template datastream definition
andreidan Jul 9, 2020
fb6b62a
Fix yaml test
andreidan Jul 9, 2020
65c1d5d
Update index templates doc
andreidan Jul 9, 2020
9646bdc
Mention only the empty body `data_stream`
andreidan Jul 9, 2020
c920a53
Merge branch 'master' into default-ds-timestamp-definition
elasticmachine Jul 9, 2020
cce093d
Use the empty `data_stream` definition in yaml tests
andreidan Jul 9, 2020
8d1d819
Disablle more yaml tests in 7.9
andreidan Jul 10, 2020
69a34f7
Merge branch 'master' into default-ds-timestamp-definition
elasticmachine Jul 13, 2020
d55060d
Remove timestamp_field from data_stream definition
andreidan Jul 13, 2020
98b23e5
Handle equals and hashcode for empty DataStreamTemplate
andreidan Jul 13, 2020
1a73aaf
Update xpack templates to not specify the timestamp_field
andreidan Jul 13, 2020
0bc0ae4
Merge branch 'master' into default-ds-timestamp-definition
andreidan Jul 13, 2020
8a1a75d
Deleting this test as it's been moved to the `data-streams` module
andreidan Jul 13, 2020
0b4b0b2
Fix merge
andreidan Jul 13, 2020
aaa6567
Drop timestamp_field from data_stream definitions
andreidan Jul 13, 2020
7573760
Spotless
andreidan Jul 13, 2020
6dad7fb
DOCS: remove mention of the `timestamp_field` in the `data_stream` de…
andreidan Jul 13, 2020
f7ac1ef
Fix post merge compilation errors
andreidan Jul 13, 2020
c62f1d4
DOCS: update ilm tutorial
andreidan Jul 13, 2020
23b8cd6
Drop the timestamp_field definition from tests
andreidan Jul 13, 2020
40de34b
Merge branch 'master' into default-ds-timestamp-definition
elasticmachine Jul 13, 2020
b81a69f
Fix docs
andreidan Jul 13, 2020
2543e17
Disable bwc tests
andreidan Jul 13, 2020
6c5d3f7
Remove more timestamp_field declarations
andreidan Jul 13, 2020
c2a750b
Fix TimeSeriesDataStreamsIT
andreidan Jul 13, 2020
fc19175
Fix TransformRestTestCase
andreidan Jul 14, 2020
3c737c2
Fix DataStreamsUpgradeIT
andreidan Jul 14, 2020
fc7fb1e
Merge branch 'master' into default-ds-timestamp-definition
andreidan Jul 14, 2020
d75db9e
Fix merge
andreidan Jul 14, 2020
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ tasks.register("verifyVersions") {
*/

boolean bwc_tests_enabled = false
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/59244" /* place a PR link here when committing bwc changes */
final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/59317" /* place a PR link here when committing bwc changes */
if (bwc_tests_enabled == false) {
if (bwc_tests_disabled_issue.isEmpty()) {
throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ public void testDataStreams() throws Exception {
CompressedXContent mappings = new CompressedXContent("{\"properties\":{\"@timestamp\":{\"type\":\"date\"}}}");
Template template = new Template(null, mappings, null);
ComposableIndexTemplate indexTemplate = new ComposableIndexTemplate(Collections.singletonList(dataStreamName), template,
Collections.emptyList(), 1L, 1L, new HashMap<>(), new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
Collections.emptyList(), 1L, 1L, new HashMap<>(), new ComposableIndexTemplate.DataStreamTemplate());
PutComposableIndexTemplateRequest putComposableIndexTemplateRequest =
new PutComposableIndexTemplateRequest().name("ds-template").create(true).indexTemplate(indexTemplate);
AcknowledgedResponse response = execute(putComposableIndexTemplateRequest,
Expand Down
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("@timestamp");
dataStreamTemplate = new ComposableIndexTemplate.DataStreamTemplate();
}
return new ComposableIndexTemplate(patterns, randomTemplate(), composedOf, priority, version, meta, dataStreamTemplate);
}
Expand Down
28 changes: 7 additions & 21 deletions docs/reference/data-streams/change-mappings-and-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ PUT /_ilm/policy/logs_policy
PUT /_index_template/logs_data_stream
{
"index_patterns": [ "logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand All @@ -69,9 +67,7 @@ PUT /_index_template/logs_data_stream
PUT /_index_template/new_logs_data_stream
{
"index_patterns": [ "new_logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand Down Expand Up @@ -124,9 +120,7 @@ for a new field, `message`, to the template.
PUT /_index_template/logs_data_stream
{
"index_patterns": [ "logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand Down Expand Up @@ -193,9 +187,7 @@ mapping parameter to `true`.
PUT /_index_template/logs_data_stream
{
"index_patterns": [ "logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand Down Expand Up @@ -279,9 +271,7 @@ template's `index.refresh_interval` index setting to `30s` (30 seconds).
PUT /_index_template/logs_data_stream
{
"index_patterns": [ "logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand Down Expand Up @@ -345,9 +335,7 @@ The following <<indices-templates,put index template API>> requests adds new
PUT /_index_template/logs_data_stream
{
"index_patterns": [ "logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand Down Expand Up @@ -460,9 +448,7 @@ uses the `logs_data_stream` template as its basis, with the following changes:
PUT /_index_template/new_logs_data_stream
{
"index_patterns": [ "new_logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand Down
7 changes: 2 additions & 5 deletions docs/reference/data-streams/set-up-a-data-stream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ this pattern.
----
====

* A `data_stream` definition containing `@timestamp` in the `timestamp_field`
property. The `@timestamp` field must be included in every document indexed to
* A `data_stream` object with an empty body (`{ }`).
the data stream.

The template can also contain:
Expand Down Expand Up @@ -173,9 +172,7 @@ configures the `logs_data_stream` template.
PUT /_index_template/logs_data_stream
{
"index_patterns": [ "logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"settings": {
"index.lifecycle.name": "logs_policy"
Expand Down
11 changes: 9 additions & 2 deletions docs/reference/data-streams/use-a-data-stream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,15 @@ the following:
PUT /_index_template/logs_data_stream
{
"index_patterns": [ "logs*" ],
"data_stream": {
"timestamp_field": "@timestamp"
"data_stream": {},
"template": {
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
}
}
}
}
}

Expand Down
16 changes: 6 additions & 10 deletions docs/reference/ilm/ilm-tutorial.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,17 @@ with the options you specify.
PUT _index_template/timeseries_template
{
"index_patterns": ["timeseries"], <1>
"data_stream": {
"timestamp_field": "@timestamp" <2>
},
"data_stream": {},
"template": {
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1,
"index.lifecycle.name": "timeseries_policy" <3>
"index.lifecycle.name": "timeseries_policy" <2>
},
"mappings": {
"properties": {
"@timestamp": {
"type": "date" <4>
"type": "date" <3>
}
}
}
Expand All @@ -143,11 +141,9 @@ PUT _index_template/timeseries_template
// TEST[continued]

<1> Apply the template when a document is indexed into the `timeseries` target.
<2> Identifies the timestamp field for the data source. This field must be present
in all documents indexed into the `timeseries` data stream.
<3> The name of the {ilm-init} policy used to manage the data stream.
<4> A <<date,`date`>> or <<date_nanos,`date_nanos`>> field mapping for the
timestamp field specified in the `timestamp_field` property
<2> The name of the {ilm-init} policy used to manage the data stream.
<3> A <<date,`date`>> or <<date_nanos,`date_nanos`>> field mapping for the
"@timestamp" field the data stream will use.
====

[discrete]
Expand Down
4 changes: 1 addition & 3 deletions docs/reference/indices/create-data-stream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ PUT /_index_template/template
}
}
},
"data_stream": {
"timestamp_field": "@timestamp"
}
"data_stream": {}
}
----
////
Expand Down
4 changes: 1 addition & 3 deletions docs/reference/indices/delete-data-stream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ PUT /_index_template/template
}
}
},
"data_stream": {
"timestamp_field": "@timestamp"
}
"data_stream": {}
}

PUT /_data_stream/my-data-stream
Expand Down
4 changes: 1 addition & 3 deletions docs/reference/indices/get-data-stream.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ PUT /_ilm/policy/my-lifecycle-policy
PUT /_index_template/my-index-template
{
"index_patterns": [ "my-data-stream*" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand Down
11 changes: 1 addition & 10 deletions docs/reference/indices/index-templates.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -496,19 +496,10 @@ PUT /_index_template/template_1
}
}
},
"data_stream": {
"timestamp_field": "@timestamp"
}
"data_stream": {}
}
--------------------------------------------------

Required properties of a data stream definition:

`timestamp_field`::
(Required, string) The name of the timestamp field. This field must be present
in all documents indexed into the data stream and must be of type
<<date, `date`>> or <<date_nanos, `date_nanos`>>.

[[multiple-component-templates]]
===== Composing multiple component templates

Expand Down
4 changes: 1 addition & 3 deletions docs/reference/indices/resolve.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ PUT /my-index/_alias/f-alias
PUT /_index_template/foo_data_stream
{
"index_patterns": [ "foo" ],
"data_stream": {
"timestamp_field": "@timestamp"
},
"data_stream": {},
"template": {
"mappings": {
"properties": {
Expand Down
4 changes: 1 addition & 3 deletions docs/reference/indices/rollover-index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,7 @@ PUT _index_template/template
}
}
},
"data_stream": {
"timestamp_field": "@timestamp"
}
"data_stream": {}
}
-----------------------------------
// TEST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
setup:
- skip:
version: "7.8.99 - "
reason: "resolve index api only supported in 7.9+"
version: "7.9.99 - "
reason: "enable in 7.9+ when backported"
features: allowed_warnings

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void testUsageOfDataStreamFails() throws IOException {
Exception expectedException = expectThrows(Exception.class, () -> ComposableIndexTemplate.parse(parser));

ComposableIndexTemplate template = new ComposableIndexTemplate(List.of("logs-*-*"), null, null, null, null,
null, new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
null, new ComposableIndexTemplate.DataStreamTemplate());
Exception e = expectThrows(IllegalArgumentException.class, () -> client().execute(PutComposableIndexTemplateAction.INSTANCE,
new PutComposableIndexTemplateAction.Request("my-it").indexTemplate(template)).actionGet());
Exception actualException = (Exception) e.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ConstructingObjectParser;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
Expand Down Expand Up @@ -247,64 +248,49 @@ public String toString() {

public static class DataStreamTemplate implements Writeable, ToXContentObject {

private static final ConstructingObjectParser<DataStreamTemplate, Void> PARSER = new ConstructingObjectParser<>(
private static final ObjectParser<DataStreamTemplate, Void> PARSER = new ObjectParser<>(
"data_stream_template",
args -> new DataStreamTemplate((String) args[0])
DataStreamTemplate::new
);

static {
PARSER.declareString(ConstructingObjectParser.constructorArg(), DataStream.TIMESTAMP_FIELD_FIELD);
}

private final String timestampField;

public DataStreamTemplate(String timestampField) {
if (FIXED_TIMESTAMP_FIELD.equals(timestampField) == false) {
throw new IllegalArgumentException("unexpected timestamp field [" + timestampField + "]");
}

this.timestampField = timestampField;
public DataStreamTemplate() {
}

public String getTimestampField() {
return timestampField;
return FIXED_TIMESTAMP_FIELD;
}

DataStreamTemplate(StreamInput in) throws IOException {
this(in.readString());
DataStreamTemplate(StreamInput in) {
this();
}

/**
* @return a mapping snippet for a backing index with `_data_stream_timestamp` meta field mapper properly configured.
*/
public Map<String, Object> getDataSteamMappingSnippet() {
return Map.of(MapperService.SINGLE_MAPPING_NAME, Map.of("_data_stream_timestamp", Map.of("path", timestampField)));
return Map.of(MapperService.SINGLE_MAPPING_NAME, Map.of("_data_stream_timestamp", Map.of("path", FIXED_TIMESTAMP_FIELD)));
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(timestampField);
}

@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field(DataStream.TIMESTAMP_FIELD_FIELD.getPreferredName(), timestampField);
builder.endObject();
return builder;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DataStreamTemplate that = (DataStreamTemplate) o;
return timestampField.equals(that.timestampField);
return o != null && getClass() == o.getClass();
}

@Override
public int hashCode() {
return Objects.hash(timestampField);
return DataStreamTemplate.class.hashCode();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void testResolveAutoCreateDataStreams() {
Metadata metadata;
{
Metadata.Builder mdBuilder = new Metadata.Builder();
DataStreamTemplate dataStreamTemplate = new DataStreamTemplate("@timestamp");
DataStreamTemplate dataStreamTemplate = new DataStreamTemplate();
mdBuilder.put("1", new ComposableIndexTemplate(List.of("legacy-logs-*"), null, null, 10L, null, null, null));
mdBuilder.put("2", new ComposableIndexTemplate(List.of("logs-*"), null, null, 20L, null, null, dataStreamTemplate));
mdBuilder.put("3", new ComposableIndexTemplate(List.of("logs-foobar"), null, null, 30L, null, null, dataStreamTemplate));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
import org.elasticsearch.common.CheckedFunction;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.settings.IndexScopedSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.json.JsonXContent;
Expand Down Expand Up @@ -539,7 +539,7 @@ public void testRolloverClusterState() throws Exception {
public void testRolloverClusterStateForDataStream() throws Exception {
final DataStream dataStream = DataStreamTests.randomInstance();
ComposableIndexTemplate template = new ComposableIndexTemplate(List.of(dataStream.getName() + "*"), null, null, null, null, null,
new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
new ComposableIndexTemplate.DataStreamTemplate());
Metadata.Builder builder = Metadata.builder();
builder.put("template", template);
for (Index index : dataStream.getIndices()) {
Expand Down Expand Up @@ -634,7 +634,7 @@ public void testValidation() throws Exception {
sourceIndexName = dataStream.getIndices().get(dataStream.getIndices().size() - 1).getName();
defaultRolloverIndexName = DataStream.getDefaultBackingIndexName(dataStream.getName(), dataStream.getGeneration() + 1);
ComposableIndexTemplate template = new ComposableIndexTemplate(List.of(dataStream.getName() + "*"), null, null, null, null,
null, new ComposableIndexTemplate.DataStreamTemplate("@timestamp"));
null, new ComposableIndexTemplate.DataStreamTemplate());
builder.put("template", template);
for (Index index : dataStream.getIndices()) {
builder.put(DataStreamTestHelper.getIndexMetadataBuilderForIndex(index));
Expand Down
Loading