33
33
import static org .elasticsearch .cluster .metadata .DataStreamTestHelper .newInstance ;
34
34
import static org .elasticsearch .common .settings .Settings .builder ;
35
35
import static org .elasticsearch .datastreams .DataStreamIndexSettingsProvider .FORMATTER ;
36
- import static org .hamcrest .Matchers .contains ;
37
36
import static org .hamcrest .Matchers .containsInAnyOrder ;
38
37
import static org .hamcrest .Matchers .equalTo ;
39
38
@@ -70,6 +69,18 @@ public void testGetAdditionalIndexSettings() throws Exception {
70
69
"field3": {
71
70
"type": "keyword",
72
71
"time_series_dimension": true
72
+ },
73
+ "field4": {
74
+ "type": "long",
75
+ "time_series_dimension": true
76
+ },
77
+ "field5": {
78
+ "type": "ip",
79
+ "time_series_dimension": true
80
+ },
81
+ "field6": {
82
+ "type": "boolean",
83
+ "time_series_dimension": true
73
84
}
74
85
}
75
86
}
@@ -91,7 +102,7 @@ public void testGetAdditionalIndexSettings() throws Exception {
91
102
assertThat (IndexSettings .MODE .get (result ), equalTo (IndexMode .TIME_SERIES ));
92
103
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
93
104
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
94
- assertThat (IndexMetadata .INDEX_ROUTING_PATH .get (result ), contains ("field3" ));
105
+ assertThat (IndexMetadata .INDEX_DIMENSIONS .get (result ), containsInAnyOrder ("field3" , "field4" , "field5" , "field6 " ));
95
106
}
96
107
97
108
public void testGetAdditionalIndexSettingsIndexRoutingPathAlreadyDefined () throws Exception {
@@ -105,7 +116,7 @@ public void testGetAdditionalIndexSettingsIndexRoutingPathAlreadyDefined() throw
105
116
"_doc": {
106
117
"properties": {
107
118
"field1": {
108
- "type": "keyword"
119
+ "type": "keyword",
109
120
"time_series_dimension": true
110
121
},
111
122
"field2": {
@@ -132,10 +143,11 @@ public void testGetAdditionalIndexSettingsIndexRoutingPathAlreadyDefined() throw
132
143
// The index.time_series.end_time setting requires index.mode to be set to time_series adding it here so that we read this setting:
133
144
// (in production the index.mode setting is usually provided in an index or component template)
134
145
result = builder ().put (result ).put ("index.mode" , "time_series" ).build ();
135
- assertThat (result .size (), equalTo (3 ));
146
+ assertThat (result .size (), equalTo (4 ));
136
147
assertThat (result .get (IndexSettings .MODE .getKey ()), equalTo ("time_series" ));
137
148
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
138
149
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
150
+ assertThat (IndexMetadata .INDEX_DIMENSIONS .get (result ), containsInAnyOrder ("field1" , "field2" , "field3" ));
139
151
}
140
152
141
153
public void testGetAdditionalIndexSettingsMappingsMerging () throws Exception {
@@ -206,7 +218,7 @@ public void testGetAdditionalIndexSettingsMappingsMerging() throws Exception {
206
218
assertThat (IndexSettings .MODE .get (result ), equalTo (IndexMode .TIME_SERIES ));
207
219
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
208
220
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
209
- assertThat (IndexMetadata .INDEX_ROUTING_PATH .get (result ), containsInAnyOrder ("field1" , "field3" ));
221
+ assertThat (IndexMetadata .INDEX_DIMENSIONS .get (result ), containsInAnyOrder ("field1" , "field3" ));
210
222
}
211
223
212
224
public void testGetAdditionalIndexSettingsNoMappings () {
@@ -461,7 +473,7 @@ public void testGenerateRoutingPathFromDynamicTemplate() throws Exception {
461
473
assertThat (IndexSettings .MODE .get (result ), equalTo (IndexMode .TIME_SERIES ));
462
474
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
463
475
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
464
- assertThat (IndexMetadata .INDEX_ROUTING_PATH .get (result ), containsInAnyOrder ("host.id" , "prometheus.labels.*" ));
476
+ assertThat (IndexMetadata .INDEX_DIMENSIONS .get (result ), containsInAnyOrder ("host.id" , "prometheus.labels.*" ));
465
477
}
466
478
467
479
public void testGenerateRoutingPathFromDynamicTemplateWithMultiplePathMatchEntries () throws Exception {
@@ -502,10 +514,10 @@ public void testGenerateRoutingPathFromDynamicTemplateWithMultiplePathMatchEntri
502
514
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
503
515
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
504
516
assertThat (
505
- IndexMetadata .INDEX_ROUTING_PATH .get (result ),
517
+ IndexMetadata .INDEX_DIMENSIONS .get (result ),
506
518
containsInAnyOrder ("host.id" , "xprometheus.labels.*" , "yprometheus.labels.*" )
507
519
);
508
- List <String > routingPathList = IndexMetadata .INDEX_ROUTING_PATH .get (result );
520
+ List <String > routingPathList = IndexMetadata .INDEX_DIMENSIONS .get (result );
509
521
assertEquals (3 , routingPathList .size ());
510
522
}
511
523
@@ -552,10 +564,10 @@ public void testGenerateRoutingPathFromDynamicTemplateWithMultiplePathMatchEntri
552
564
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
553
565
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
554
566
assertThat (
555
- IndexMetadata .INDEX_ROUTING_PATH .get (result ),
567
+ IndexMetadata .INDEX_DIMENSIONS .get (result ),
556
568
containsInAnyOrder ("host.id" , "xprometheus.labels.*" , "yprometheus.labels.*" )
557
569
);
558
- List <String > routingPathList = IndexMetadata .INDEX_ROUTING_PATH .get (result );
570
+ List <String > routingPathList = IndexMetadata .INDEX_DIMENSIONS .get (result );
559
571
assertEquals (3 , routingPathList .size ());
560
572
}
561
573
@@ -605,7 +617,7 @@ public void testGenerateRoutingPathFromDynamicTemplate_templateWithNoPathMatch()
605
617
assertThat (IndexSettings .MODE .get (result ), equalTo (IndexMode .TIME_SERIES ));
606
618
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
607
619
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
608
- assertThat (IndexMetadata .INDEX_ROUTING_PATH .get (result ), containsInAnyOrder ("host.id" , "prometheus.labels.*" ));
620
+ assertThat (IndexMetadata .INDEX_DIMENSIONS .get (result ), containsInAnyOrder ("host.id" , "prometheus.labels.*" ));
609
621
}
610
622
611
623
public void testGenerateRoutingPathFromDynamicTemplate_nonKeywordTemplate () throws Exception {
@@ -652,8 +664,8 @@ public void testGenerateRoutingPathFromDynamicTemplate_nonKeywordTemplate() thro
652
664
Settings result = generateTsdbSettings (mapping , now );
653
665
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
654
666
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
655
- assertThat (IndexMetadata .INDEX_ROUTING_PATH .get (result ), containsInAnyOrder ("host.id" , "prometheus.labels.*" ));
656
- assertEquals (2 , IndexMetadata .INDEX_ROUTING_PATH .get (result ).size ());
667
+ assertThat (IndexMetadata .INDEX_DIMENSIONS .get (result ), containsInAnyOrder ("host.id" , "prometheus.labels.*" ));
668
+ assertEquals (2 , IndexMetadata .INDEX_DIMENSIONS .get (result ).size ());
657
669
}
658
670
659
671
public void testGenerateRoutingPathFromPassThroughObject () throws Exception {
@@ -665,7 +677,12 @@ public void testGenerateRoutingPathFromPassThroughObject() throws Exception {
665
677
"labels": {
666
678
"type": "passthrough",
667
679
"time_series_dimension": true,
668
- "priority": 2
680
+ "priority": 2,
681
+ "properties": {
682
+ "label1": {
683
+ "type": "keyword"
684
+ }
685
+ }
669
686
},
670
687
"metrics": {
671
688
"type": "passthrough",
@@ -683,7 +700,7 @@ public void testGenerateRoutingPathFromPassThroughObject() throws Exception {
683
700
assertThat (IndexSettings .MODE .get (result ), equalTo (IndexMode .TIME_SERIES ));
684
701
assertThat (IndexSettings .TIME_SERIES_START_TIME .get (result ), equalTo (now .minusMillis (DEFAULT_LOOK_BACK_TIME .getMillis ())));
685
702
assertThat (IndexSettings .TIME_SERIES_END_TIME .get (result ), equalTo (now .plusMillis (DEFAULT_LOOK_AHEAD_TIME .getMillis ())));
686
- assertThat (IndexMetadata .INDEX_ROUTING_PATH .get (result ), containsInAnyOrder ("labels.*" ));
703
+ assertThat (IndexMetadata .INDEX_DIMENSIONS .get (result ), containsInAnyOrder ("labels.*" ));
687
704
}
688
705
689
706
private Settings generateTsdbSettings (String mapping , Instant now ) throws IOException {
0 commit comments