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: Make time boundaries settings required in tsdb indices #81146

Merged
merged 12 commits into from
Dec 1, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.elasticsearch.cluster.metadata.MetadataIndexStateService;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.time.DateUtils;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.CheckedFunction;
Expand Down Expand Up @@ -307,6 +308,8 @@ private int createTimeSeriesModeIndex(int replicas) throws IOException {
mappingsAndSettings.field("number_of_replicas", replicas);
mappingsAndSettings.field("mode", "time_series");
mappingsAndSettings.field("routing_path", "dim");
mappingsAndSettings.field("time_series.start_time", 1L);
mappingsAndSettings.field("time_series.end_time", DateUtils.MAX_MILLIS_BEFORE_9999 - 1);
mappingsAndSettings.endObject();
}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ setup:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ tsdb:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.time.DateUtils;
import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.core.Booleans;
import org.elasticsearch.index.mapper.DateFieldMapper;
Expand Down Expand Up @@ -322,6 +323,8 @@ private void createTsdbIndex() throws IOException {
indexSpec.startObject("settings").startObject("index");
indexSpec.field("mode", "time_series");
indexSpec.array("routing_path", new String[] { "dim" });
indexSpec.field("time_series.start_time", 1L);
indexSpec.field("time_series.end_time", DateUtils.MAX_MILLIS_BEFORE_9999 - 1);
indexSpec.endObject().endObject();
createIndex.setJsonEntity(Strings.toString(indexSpec.endObject()));
client().performRequest(createIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ setup:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
number_of_shards: 10
number_of_replicas: 1
mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ enable:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -52,6 +55,10 @@ no sort field:
settings:
index:
mode: time_series
routing_path: foo
time_series:
start_time: 1
end_time: 253402300799998
sort.field: ['a']

---
Expand All @@ -68,6 +75,10 @@ no sort order:
settings:
index:
mode: time_series
routing_path: foo
time_series:
start_time: 1
end_time: 253402300799998
sort.order: ['DESC']

---
Expand All @@ -84,6 +95,10 @@ no sort mode:
settings:
index:
mode: time_series
routing_path: foo
time_series:
start_time: 1
end_time: 253402300799998
sort.mode: ['MIN']

---
Expand All @@ -100,6 +115,10 @@ no sort missing:
settings:
index:
mode: time_series
routing_path: foo
time_series:
start_time: 1
end_time: 253402300799998
sort.missing: ['_last']

---
Expand All @@ -116,6 +135,10 @@ no partitioning:
settings:
index:
mode: time_series
routing_path: foo
time_series:
start_time: 1
end_time: 253402300799998
shards: 5
routing_partition_size: 2

Expand All @@ -133,7 +156,10 @@ routing_path required:
settings:
index:
mode: time_series
shards: 5
time_series:
start_time: 1
end_time: 253402300799998
number_of_shards: 5

---
routing_path is not allowed in standard mode:
Expand Down Expand Up @@ -165,6 +191,9 @@ routing required:
index:
mode: time_series
routing_path: foo
time_series:
start_time: 1
end_time: 253402300799998
mappings:
_routing:
required: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ date:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be nice to have something a little more realistic here - probably jut 2021-04-28T00:00:00Z to 2021-04-29 or something like that.

number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -59,6 +62,9 @@ date_nanos:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -105,6 +111,9 @@ automatically add with date:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -150,6 +159,9 @@ reject @timestamp with wrong type:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand All @@ -172,6 +184,9 @@ reject timestamp meta field with wrong type:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand All @@ -192,6 +207,9 @@ enable timestamp meta field:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -219,6 +237,9 @@ reject bad timestamp meta field:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand All @@ -238,6 +259,9 @@ write without timestamp:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -275,6 +299,9 @@ explicitly enable timestamp meta field:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ ecs style:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -64,6 +67,9 @@ top level dim object:
index:
mode: time_series
routing_path: [dim.*]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -120,6 +126,9 @@ non keyword matches routing_path:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid, "@timestamp"]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down Expand Up @@ -161,6 +170,9 @@ runtime field matching routing path:
index:
mode: time_series
routing_path: [dim.*]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
properties:
"@timestamp":
Expand Down Expand Up @@ -200,6 +212,9 @@ runtime field matching routing path:
index:
mode: time_series
routing_path: [dim.*]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
properties:
"@timestamp":
Expand Down Expand Up @@ -234,6 +249,9 @@ runtime field matching routing path:
index:
mode: time_series
routing_path: [dim.*]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
properties:
"@timestamp":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ teardown:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
number_of_replicas: 0
number_of_shards: 2
mappings:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ setup:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
properties:
"@timestamp":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ setup:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
properties:
"@timestamp":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ add dimensions with put_mapping:
index:
mode: time_series
routing_path: [metricset, k8s.pod.uid]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
properties:
"@timestamp":
Expand Down Expand Up @@ -62,6 +65,9 @@ add dimensions to no dims with dynamic_template over index:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
dynamic_templates:
- keywords:
Expand Down Expand Up @@ -107,6 +113,9 @@ add dimensions to no dims with dynamic_template over bulk:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
dynamic_templates:
- keywords:
Expand Down Expand Up @@ -152,6 +161,9 @@ add dimensions to some dims with dynamic_template over index:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
dynamic_templates:
- keywords:
Expand Down Expand Up @@ -201,6 +213,9 @@ add dimensions to some dims with dynamic_template over bulk:
index:
mode: time_series
routing_path: [metricset]
time_series:
start_time: 1
end_time: 253402300799998
mappings:
dynamic_templates:
- keywords:
Expand Down
Loading