diff --git a/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java b/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java index fc4a39acf853b..8b723bbebfcd7 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java +++ b/test/framework/src/main/java/org/elasticsearch/test/ClusterServiceUtils.java @@ -121,11 +121,17 @@ public static ClusterService createClusterService(ThreadPool threadPool, Cluster public static ClusterService createClusterService(ThreadPool threadPool, DiscoveryNode localNode, ClusterSettings clusterSettings) { Settings settings = Settings.builder().put("node.name", "test").put("cluster.name", "ClusterServiceTests").build(); + return createClusterService(threadPool, localNode, settings, clusterSettings); + } + + public static ClusterService createClusterService( + ThreadPool threadPool, DiscoveryNode localNode, Settings nodeSettings, ClusterSettings clusterSettings + ) { ClusterService clusterService = new ClusterService( - settings, + nodeSettings, clusterSettings, threadPool, - new TaskManager(settings, threadPool, Collections.emptySet(), Tracer.NOOP) + new TaskManager(nodeSettings, threadPool, Collections.emptySet(), Tracer.NOOP) ); clusterService.setNodeConnectionsService(createNoOpNodeConnectionsService()); ClusterState initialClusterState = ClusterState.builder(new ClusterName(ClusterServiceUtils.class.getSimpleName())) diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/logs-apm.app-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/logs-apm.app-fallback@ilm.yaml new file mode 100644 index 0000000000000..9d49bb027c217 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/logs-apm.app-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for logs-apm.app if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: logs-apm.app_logs-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/logs-apm.error-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/logs-apm.error-fallback@ilm.yaml new file mode 100644 index 0000000000000..b3e2bd2a631a9 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/logs-apm.error-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for logs-apm.error if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: logs-apm.error_logs-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.app-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.app-fallback@ilm.yaml new file mode 100644 index 0000000000000..99acbea08ec04 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.app-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.app if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.app_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.internal-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.internal-fallback@ilm.yaml new file mode 100644 index 0000000000000..cbc93e77bc1b0 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.internal-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.internal if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.internal_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.10m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.10m-fallback@ilm.yaml new file mode 100644 index 0000000000000..8395cc713fd5e --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.10m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_destination.10m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_destination_10m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.1m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.1m-fallback@ilm.yaml new file mode 100644 index 0000000000000..81f3a5da9803d --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.1m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_destination.1m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_destination_1m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.60m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.60m-fallback@ilm.yaml new file mode 100644 index 0000000000000..5278114a7cc1f --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_destination.60m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_destination.60m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_destination_60m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.10m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.10m-fallback@ilm.yaml new file mode 100644 index 0000000000000..18752839eba47 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.10m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_summary.10m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_summary_10m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.1m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.1m-fallback@ilm.yaml new file mode 100644 index 0000000000000..118b76438e763 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.1m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_summary.1m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_summary_1m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.60m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.60m-fallback@ilm.yaml new file mode 100644 index 0000000000000..c0d825d6cbb31 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_summary.60m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_summary.60m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_summary_60m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.10m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.10m-fallback@ilm.yaml new file mode 100644 index 0000000000000..7f4c0310ed007 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.10m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_transaction.10m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_transaction_10m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.1m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.1m-fallback@ilm.yaml new file mode 100644 index 0000000000000..44ea69d476954 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.1m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_transaction.1m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_transaction_1m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.60m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.60m-fallback@ilm.yaml new file mode 100644 index 0000000000000..5be8368ab1efb --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.service_transaction.60m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.service_transaction.60m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.service_transaction_60m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.10m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.10m-fallback@ilm.yaml new file mode 100644 index 0000000000000..6bd837af53e79 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.10m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.transaction.10m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.transaction_10m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.1m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.1m-fallback@ilm.yaml new file mode 100644 index 0000000000000..468dff5b81a8d --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.1m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.transaction.1m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.transaction_1m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.60m-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.60m-fallback@ilm.yaml new file mode 100644 index 0000000000000..17cf9c3316200 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/metrics-apm.transaction.60m-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for metrics-apm.transaction.60m if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: metrics-apm.transaction_60m_metrics-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm-fallback@ilm.yaml new file mode 100644 index 0000000000000..7febfb0dbdd1e --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for traces-apm if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: traces-apm.traces-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm.rum-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm.rum-fallback@ilm.yaml new file mode 100644 index 0000000000000..3c894601f6717 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm.rum-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for traces-apm.rum if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: traces-apm.rum_traces-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm.sampled-fallback@ilm.yaml b/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm.sampled-fallback@ilm.yaml new file mode 100644 index 0000000000000..bd892f8e64e83 --- /dev/null +++ b/x-pack/plugin/apm-data/src/main/resources/component-templates/traces-apm.sampled-fallback@ilm.yaml @@ -0,0 +1,11 @@ +--- +version: ${xpack.apmdata.template.version} +_meta: + description: Fallback to ILM policy for traces-apm.sampled if DSL not defined + managed: true +template: + settings: + index: + lifecycle: + name: traces-apm.sampled_traces-default_policy + prefer_ilm: false diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/logs-apm.app@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/logs-apm.app@template.yaml index 21cad50f3fe90..a84d5b899d75c 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/logs-apm.app@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/logs-apm.app@template.yaml @@ -12,6 +12,7 @@ composed_of: - apm@settings - apm-10d@lifecycle - logs-apm@settings +- logs-apm.app-fallback@ilm - logs@custom - logs-apm.app@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/logs-apm.error@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/logs-apm.error@template.yaml index 2cfa7b454722f..71b7859230d16 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/logs-apm.error@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/logs-apm.error@template.yaml @@ -14,6 +14,7 @@ composed_of: - apm-10d@lifecycle - logs-apm@settings - logs-apm.error@mappings +- logs-apm.error-fallback@ilm - logs@custom - logs-apm.error@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.app@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.app@template.yaml index a3c7ab7c05193..e8f8ce3b25760 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.app@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.app@template.yaml @@ -13,6 +13,7 @@ composed_of: - apm-90d@lifecycle - metrics-apm@mappings - metrics-apm@settings +- metrics-apm.app-fallback@ilm - metrics@custom - metrics-apm.app@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.internal@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.internal@template.yaml index 4c7df377a6cfa..7e73dde13156d 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.internal@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.internal@template.yaml @@ -14,6 +14,7 @@ composed_of: - apm-90d@lifecycle - metrics-apm@mappings - metrics-apm@settings +- metrics-apm.internal-fallback@ilm - metrics@custom - metrics-apm.internal@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.10m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.10m@template.yaml index 63c9ff9c3b988..f10da8d87e025 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.10m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.10m@template.yaml @@ -16,6 +16,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_destination@mappings +- metrics-apm.service_destination.10m-fallback@ilm - metrics@custom - metrics-apm.service_destination.10m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.1m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.1m@template.yaml index 6995a2d09b12e..7e5ab0f2d87b2 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.1m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.1m@template.yaml @@ -15,6 +15,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_destination@mappings +- metrics-apm.service_destination.1m-fallback@ilm - metrics@custom - metrics-apm.service_destination.1m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.60m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.60m@template.yaml index b39d0beca3740..a087e8ea8b403 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.60m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_destination.60m@template.yaml @@ -16,6 +16,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_destination@mappings +- metrics-apm.service_destination.60m-fallback@ilm - metrics@custom - metrics-apm.service_destination.60m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.10m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.10m@template.yaml index 8d92b21866bb8..37781991d9c4d 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.10m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.10m@template.yaml @@ -16,6 +16,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_summary@mappings +- metrics-apm.service_summary.10m-fallback@ilm - metrics@custom - metrics-apm.service_summary.10m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.1m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.1m@template.yaml index de19df330aa0e..0609b6af02d05 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.1m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.1m@template.yaml @@ -15,6 +15,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_summary@mappings +- metrics-apm.service_summary.1m-fallback@ilm - metrics@custom - metrics-apm.service_summary.1m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.60m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.60m@template.yaml index 002676eb08cc1..f9eca377482c3 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.60m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_summary.60m@template.yaml @@ -16,6 +16,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_summary@mappings +- metrics-apm.service_summary.60m-fallback@ilm - metrics@custom - metrics-apm.service_summary.60m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.10m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.10m@template.yaml index 549af3942dcd3..47605b19424c3 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.10m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.10m@template.yaml @@ -16,6 +16,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_transaction@mappings +- metrics-apm.service_transaction.10m-fallback@ilm - metrics@custom - metrics-apm.service_transaction.10m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.1m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.1m@template.yaml index 9bdacfc337663..ad8a983535d3c 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.1m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.1m@template.yaml @@ -15,6 +15,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_transaction@mappings +- metrics-apm.service_transaction.1m-fallback@ilm - metrics@custom - metrics-apm.service_transaction.1m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.60m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.60m@template.yaml index 8bcbeb53c74fe..dea2c3382ecca 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.60m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.service_transaction.60m@template.yaml @@ -16,6 +16,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.service_transaction@mappings +- metrics-apm.service_transaction.60m-fallback@ilm - metrics@custom - metrics-apm.service_transaction.60m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.10m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.10m@template.yaml index 68c1dc0f31c1e..08c0494d4cf58 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.10m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.10m@template.yaml @@ -16,6 +16,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.transaction@mappings +- metrics-apm.transaction.10m-fallback@ilm - metrics@custom - metrics-apm.transaction.10m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.1m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.1m@template.yaml index 6065f6e12f999..221a988e2371f 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.1m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.1m@template.yaml @@ -15,6 +15,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.transaction@mappings +- metrics-apm.transaction.1m-fallback@ilm - metrics@custom - metrics-apm.transaction.1m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.60m@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.60m@template.yaml index d8889ceb63f87..2f50fe63875fe 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.60m@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/metrics-apm.transaction.60m@template.yaml @@ -16,6 +16,7 @@ composed_of: - metrics-apm@mappings - metrics-apm@settings - metrics-apm.transaction@mappings +- metrics-apm.transaction.60m-fallback@ilm - metrics@custom - metrics-apm.transaction.60m@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm.rum@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm.rum@template.yaml index d299481ff6e21..a6aeaff2b6f40 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm.rum@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm.rum@template.yaml @@ -14,6 +14,7 @@ composed_of: - apm-90d@lifecycle - traces-apm@mappings - traces-apm.rum@mappings +- traces-apm.rum-fallback@ilm - traces@custom - traces-apm.rum@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm.sampled@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm.sampled@template.yaml index 81457e2f204cb..9ec276fdad580 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm.sampled@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm.sampled@template.yaml @@ -11,6 +11,7 @@ composed_of: - traces@mappings - apm@mappings - apm@settings +- traces-apm.sampled-fallback@ilm - traces@custom - traces-apm.sampled@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm@template.yaml b/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm@template.yaml index fda953171b793..3808f132d0106 100644 --- a/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm@template.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/index-templates/traces-apm@template.yaml @@ -13,6 +13,7 @@ composed_of: - apm@settings - apm-10d@lifecycle - traces-apm@mappings +- traces-apm-fallback@ilm - traces@custom - traces-apm@custom - ecs@mappings diff --git a/x-pack/plugin/apm-data/src/main/resources/resources.yaml b/x-pack/plugin/apm-data/src/main/resources/resources.yaml index 0502a8c559ff6..a178b768c4fe9 100644 --- a/x-pack/plugin/apm-data/src/main/resources/resources.yaml +++ b/x-pack/plugin/apm-data/src/main/resources/resources.yaml @@ -1,7 +1,7 @@ # "version" holds the version of the templates and ingest pipelines installed # by xpack-plugin apm-data. This must be increased whenever an existing template or # pipeline is changed, in order for it to be updated on Elasticsearch upgrade. -version: 9 +version: 10 component-templates: # Data lifecycle. @@ -25,6 +25,26 @@ component-templates: - metrics-apm.transaction@mappings - traces-apm@mappings - traces-apm.rum@mappings + # The below files allow to fallback to ILM if DSL configurations are not present + - logs-apm.app-fallback@ilm + - logs-apm.error-fallback@ilm + - metrics-apm.app-fallback@ilm + - metrics-apm.internal-fallback@ilm + - metrics-apm.service_destination.10m-fallback@ilm + - metrics-apm.service_destination.1m-fallback@ilm + - metrics-apm.service_destination.60m-fallback@ilm + - metrics-apm.service_summary.10m-fallback@ilm + - metrics-apm.service_summary.1m-fallback@ilm + - metrics-apm.service_summary.60m-fallback@ilm + - metrics-apm.service_transaction.10m-fallback@ilm + - metrics-apm.service_transaction.1m-fallback@ilm + - metrics-apm.service_transaction.60m-fallback@ilm + - metrics-apm.transaction.10m-fallback@ilm + - metrics-apm.transaction.1m-fallback@ilm + - metrics-apm.transaction.60m-fallback@ilm + - traces-apm-fallback@ilm + - traces-apm.rum-fallback@ilm + - traces-apm.sampled-fallback@ilm index-templates: - logs-apm.app@template diff --git a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java new file mode 100644 index 0000000000000..43ac8e9f381a2 --- /dev/null +++ b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMDSLOnlyTests.java @@ -0,0 +1,106 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +package org.elasticsearch.xpack.apmdata; + +import org.elasticsearch.cluster.metadata.ComponentTemplate; +import org.elasticsearch.cluster.metadata.ComposableIndexTemplate; +import org.elasticsearch.cluster.metadata.DataStreamLifecycle; +import org.elasticsearch.cluster.node.DiscoveryNode; +import org.elasticsearch.cluster.node.DiscoveryNodeUtils; +import org.elasticsearch.cluster.service.ClusterService; +import org.elasticsearch.common.settings.ClusterSettings; +import org.elasticsearch.common.settings.Setting.Property; +import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.datastreams.DataStreamFeatures; +import org.elasticsearch.features.FeatureService; +import org.elasticsearch.test.ClusterServiceUtils; +import org.elasticsearch.test.ESTestCase; +import org.elasticsearch.threadpool.TestThreadPool; +import org.elasticsearch.threadpool.ThreadPool; +import org.elasticsearch.xcontent.NamedXContentRegistry; +import org.elasticsearch.xpack.stack.StackTemplateRegistry; +import org.elasticsearch.xpack.stack.StackTemplateRegistryAccessor; +import org.junit.After; +import org.junit.Before; + +import java.util.Set; +import java.util.Map; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import static org.elasticsearch.common.settings.Setting.boolSetting; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.empty; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.isIn; +import static org.hamcrest.Matchers.not; + +public class APMDSLOnlyTests extends ESTestCase { + private APMIndexTemplateRegistry apmIndexTemplateRegistry; + private StackTemplateRegistryAccessor stackTemplateRegistryAccessor; + private ThreadPool threadPool; + private VerifyingClient client; + + @Before + public void createRegistryAndClient() { + final ClusterSettings clusterSettings = new ClusterSettings( + Settings.builder().put( + DataStreamLifecycle.DATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAME, + "true" + ).build(), + Stream.concat( + ClusterSettings.BUILT_IN_CLUSTER_SETTINGS.stream(), + Set.of( + APMPlugin.APM_DATA_REGISTRY_ENABLED + ).stream() + ).collect(Collectors.toSet()) + ); + + threadPool = new TestThreadPool(this.getClass().getName()); + client = new VerifyingClient(threadPool); + DiscoveryNode discoveryNode = DiscoveryNodeUtils.create("node", "node"); + Settings nodeSettings = Settings.builder() + .put("node.name", "test") + .put("cluster.name", "ClusterServiceTests") + .put(DataStreamLifecycle.DATA_STREAMS_LIFECYCLE_ONLY_SETTING_NAME, true) + .build(); + ClusterService clusterService = ClusterServiceUtils.createClusterService(threadPool, discoveryNode, nodeSettings, clusterSettings); + FeatureService featureService = new FeatureService(List.of(new DataStreamFeatures())); + stackTemplateRegistryAccessor = new StackTemplateRegistryAccessor( + new StackTemplateRegistry(Settings.EMPTY, clusterService, threadPool, client, NamedXContentRegistry.EMPTY, featureService) + ); + + apmIndexTemplateRegistry = new APMIndexTemplateRegistry( + Settings.EMPTY, + clusterService, + threadPool, + client, + NamedXContentRegistry.EMPTY, + featureService + ); + apmIndexTemplateRegistry.setEnabled(true); + } + + @After + @Override + public void tearDown() throws Exception { + super.tearDown(); + threadPool.shutdownNow(); + } + + public void testNoILMComponentTemplateInstalled() throws Exception { + for (Map.Entry entry : apmIndexTemplateRegistry.getComponentTemplateConfigs().entrySet()) { + final String name = entry.getKey(); + final int atIndex = name.lastIndexOf('@'); + assertThat(atIndex, not(equalTo(-1))); + // No ILM templates should have been loaded + assertThat(name.substring(atIndex + 1), not(equalTo("ilm"))); + } + } +} diff --git a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistryTests.java b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistryTests.java index 1d6faa0f403d4..ba32e8194bf7f 100644 --- a/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistryTests.java +++ b/x-pack/plugin/apm-data/src/test/java/org/elasticsearch/xpack/apmdata/APMIndexTemplateRegistryTests.java @@ -376,6 +376,20 @@ public void testThatNothingIsInstalledWhenAllNodesAreNotUpdated() { apmIndexTemplateRegistry.clusterChanged(event); } + public void testILMComponentTemplatesInstalled() throws Exception { + int ilmFallbackCount = 0; + for (Map.Entry entry : apmIndexTemplateRegistry.getComponentTemplateConfigs().entrySet()) { + final String name = entry.getKey(); + final int atIndex = name.lastIndexOf('@'); + assertThat(atIndex, not(equalTo(-1))); + if ("ilm".equals(name.substring(atIndex + 1))) { + ilmFallbackCount++; + } + } + // Each index template should have a corresponding ILM fallback policy + assertThat(apmIndexTemplateRegistry.getComposableTemplateConfigs().size(), equalTo(ilmFallbackCount)); + } + private Map getIndependentComponentTemplateConfigs() { return apmIndexTemplateRegistry.getComponentTemplateConfigs().entrySet().stream().filter(template -> { Settings settings = template.getValue().template().settings(); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/ResourceUtils.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/ResourceUtils.java index 9840535989a7c..fc1c65be32ec3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/ResourceUtils.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/ResourceUtils.java @@ -7,12 +7,15 @@ package org.elasticsearch.xpack.core.template; +import org.elasticsearch.xpack.core.template.resources.TemplateResources; + import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Map; public class ResourceUtils { + static byte[] loadVersionedResourceUTF8(Class clazz, String name, int version, String versionProperty) { return loadVersionedResourceUTF8(clazz, name, version, versionProperty, Map.of()); } diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/YamlTemplateRegistry.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/YamlTemplateRegistry.java index a4e5d7cdc4b44..655dc309b4065 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/YamlTemplateRegistry.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/template/YamlTemplateRegistry.java @@ -33,9 +33,12 @@ import static org.elasticsearch.xpack.core.template.ResourceUtils.loadResource; import static org.elasticsearch.xpack.core.template.ResourceUtils.loadVersionedResourceUTF8; +import static org.elasticsearch.cluster.metadata.DataStreamLifecycle.isDataStreamsLifecycleOnlyMode; /** - * Creates index templates and ingest pipelines based on YAML files from resources. + * Creates index templates and ingest pipelines based on YAML files defined in resources.yaml. + * It also allows ILM files to be managed separately as per the DSL only mode for the cluster. + * The ILM names MUST end with `@ilm` for this class to mark the resource as ILM resource. */ public abstract class YamlTemplateRegistry extends IndexTemplateRegistry { private static final Logger logger = LogManager.getLogger(YamlTemplateRegistry.class); @@ -60,7 +63,7 @@ public YamlTemplateRegistry( FeatureService featureService ) { super(nodeSettings, clusterService, threadPool, client, xContentRegistry); - + final boolean dslOnlyMode = isDataStreamsLifecycleOnlyMode(clusterService.getSettings()); try { final Map resources = XContentHelper.convertToMap( YamlXContent.yamlXContent, @@ -77,11 +80,13 @@ public YamlTemplateRegistry( .orElse(Collections.emptyList()) .stream() .map(o -> (String) o) + .filter(tpl -> shouldLoadTemplate(tpl, dslOnlyMode)) .collect(Collectors.toMap(name -> name, name -> loadComponentTemplate(name, version))); composableIndexTemplates = Optional.ofNullable(indexTemplateNames) .orElse(Collections.emptyList()) .stream() .map(o -> (String) o) + .filter(tpl -> shouldLoadTemplate(tpl, dslOnlyMode)) .collect(Collectors.toMap(name -> name, name -> loadIndexTemplate(name, version))); ingestPipelines = Optional.ofNullable(ingestPipelineConfigs) .orElse(Collections.emptyList()) @@ -166,6 +171,13 @@ public List getIngestPipelines() { protected abstract String getVersionProperty(); + private boolean shouldLoadTemplate(String name, boolean dslOnlyMode) { + if (dslOnlyMode && name.endsWith("@ilm")) { + return false; + } + return true; + } + private ComponentTemplate loadComponentTemplate(String name, int version) { try { final byte[] content = loadVersionedResourceUTF8(