Skip to content

Commit 297a013

Browse files
authored
Add tsdb metrics builtin component template (#97602)
Fleet is currently hard coded to set index.codec to best_compression (deflate compression). This is good for most data streams, except for data streams were tsdb is enabled. Ideally Fleet doesn't need to set this setting at all and Elasticsearch's default would be good. But unfortunately this isn't the case. It default to default (lz4 - optimised for speed), which in would mean much higher disk space usage. Ideally the default would be default when synthetic source is enabled and otherwise best_compression. Changing this now, would mean a breaking change. Instead Fleet like to depend on Elasticsearch's internal component templates. To at least abstract some of the internal details away. The metrics-settings is ok for non tsdb, but there is no component template for tsdb metrics. This PR adds this. Relates to elastic/kibana#160288
1 parent ddc470c commit 297a013

File tree

7 files changed

+42
-0
lines changed

7 files changed

+42
-0
lines changed

docs/changelog/97602.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 97602
2+
summary: Add tsdb metrics builtin component template
3+
area: "TSDB"
4+
type: enhancement
5+
issues: []

docs/reference/indices/put-component-template.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Name of the component template to create.
9595
- `logs-settings`
9696
- `metrics-mappings`
9797
- `metrics-settings`
98+
- `metrics-tsdb-settings`
9899
- `synthetics-mapping`
99100
- `synthetics-settings`
100101
// end::built-in-component-templates[]

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,6 +1843,7 @@ protected static boolean isXPackTemplate(String name) {
18431843
case "logs-mappings":
18441844
case "metrics":
18451845
case "metrics-settings":
1846+
case "metrics-tsdb-settings":
18461847
case "metrics-mappings":
18471848
case "synthetics":
18481849
case "synthetics-settings":
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"template": {
3+
"settings": {
4+
"index": {
5+
"lifecycle": {
6+
"name": "metrics"
7+
},
8+
"query": {
9+
"default_field": ["message"]
10+
}
11+
}
12+
}
13+
},
14+
"_meta": {
15+
"description": "default settings for the metrics index template installed by x-pack",
16+
"managed": true
17+
},
18+
"version": ${xpack.stack.template.version}
19+
}

x-pack/plugin/stack/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/stack/10_basic.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ setup:
3434
cluster.get_component_template:
3535
name: metrics-settings
3636

37+
- do:
38+
cluster.get_component_template:
39+
name: metrics-tsdb-settings
40+
3741
- do:
3842
indices.get_index_template:
3943
name: logs

x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public class StackTemplateRegistry extends IndexTemplateRegistry {
8383
//////////////////////////////////////////////////////////
8484
public static final String METRICS_MAPPINGS_COMPONENT_TEMPLATE_NAME = "metrics-mappings";
8585
public static final String METRICS_SETTINGS_COMPONENT_TEMPLATE_NAME = "metrics-settings";
86+
public static final String METRICS_TSDB_SETTINGS_COMPONENT_TEMPLATE_NAME = "metrics-tsdb-settings";
8687
public static final String METRICS_ILM_POLICY_NAME = "metrics";
8788
public static final String METRICS_INDEX_TEMPLATE_NAME = "metrics";
8889

@@ -196,6 +197,12 @@ protected List<LifecyclePolicy> getLifecyclePolicies() {
196197
REGISTRY_VERSION,
197198
TEMPLATE_VERSION_VARIABLE
198199
),
200+
new IndexTemplateConfig(
201+
METRICS_TSDB_SETTINGS_COMPONENT_TEMPLATE_NAME,
202+
"/metrics-tsdb-settings.json",
203+
REGISTRY_VERSION,
204+
TEMPLATE_VERSION_VARIABLE
205+
),
199206
new IndexTemplateConfig(
200207
SYNTHETICS_MAPPINGS_COMPONENT_TEMPLATE_NAME,
201208
"/synthetics-mappings.json",

x-pack/plugin/stack/src/test/java/org/elasticsearch/xpack/stack/StackTemplateRegistryTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ public void testSameOrHigherVersionTemplateNotUpgraded() {
382382
versions.put(StackTemplateRegistry.LOGS_SETTINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
383383
versions.put(StackTemplateRegistry.LOGS_MAPPINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
384384
versions.put(StackTemplateRegistry.METRICS_SETTINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
385+
versions.put(StackTemplateRegistry.METRICS_TSDB_SETTINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
385386
versions.put(StackTemplateRegistry.METRICS_MAPPINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
386387
versions.put(StackTemplateRegistry.SYNTHETICS_SETTINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
387388
versions.put(StackTemplateRegistry.SYNTHETICS_MAPPINGS_COMPONENT_TEMPLATE_NAME, StackTemplateRegistry.REGISTRY_VERSION);
@@ -424,6 +425,10 @@ public void testSameOrHigherVersionTemplateNotUpgraded() {
424425
StackTemplateRegistry.METRICS_SETTINGS_COMPONENT_TEMPLATE_NAME,
425426
StackTemplateRegistry.REGISTRY_VERSION + randomIntBetween(1, 1000)
426427
);
428+
versions.put(
429+
StackTemplateRegistry.METRICS_TSDB_SETTINGS_COMPONENT_TEMPLATE_NAME,
430+
StackTemplateRegistry.REGISTRY_VERSION + randomIntBetween(1, 1000)
431+
);
427432
versions.put(
428433
StackTemplateRegistry.METRICS_MAPPINGS_COMPONENT_TEMPLATE_NAME,
429434
StackTemplateRegistry.REGISTRY_VERSION + randomIntBetween(1, 1000)

0 commit comments

Comments
 (0)