Skip to content

Commit

Permalink
[plugin/apm-data]Fallback to ILM for non-dsl-only mode if DSL unavail…
Browse files Browse the repository at this point in the history
…able (#112759)
  • Loading branch information
lahsivjar authored Sep 16, 2024
1 parent 2354e8f commit efdd0c3
Show file tree
Hide file tree
Showing 46 changed files with 449 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,20 @@ 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.EMPTY, clusterSettings);
}

public static ClusterService createClusterService(
ThreadPool threadPool,
DiscoveryNode localNode,
Settings providedSettings,
ClusterSettings clusterSettings
) {
Settings settings = Settings.builder()
.put("node.name", "test")
.put("cluster.name", "ClusterServiceTests")
.put(providedSettings)
.build();
ClusterService clusterService = new ClusterService(
settings,
clusterSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
import org.elasticsearch.xpack.core.ClientHelper;
import org.elasticsearch.xpack.core.template.YamlTemplateRegistry;

import java.util.function.Predicate;

import static org.elasticsearch.cluster.metadata.DataStreamLifecycle.isDataStreamsLifecycleOnlyMode;
import static org.elasticsearch.xpack.apmdata.APMPlugin.APM_DATA_REGISTRY_ENABLED;

/**
Expand All @@ -33,7 +36,15 @@ public APMIndexTemplateRegistry(
NamedXContentRegistry xContentRegistry,
FeatureService featureService
) {
super(nodeSettings, clusterService, threadPool, client, xContentRegistry, featureService);
super(
nodeSettings,
clusterService,
threadPool,
client,
xContentRegistry,
featureService,
templateFilter(isDataStreamsLifecycleOnlyMode(clusterService.getSettings()))
);
}

@Override
Expand All @@ -58,4 +69,9 @@ protected String getVersionProperty() {
protected String getOrigin() {
return ClientHelper.APM_ORIGIN;
}

private static Predicate<String> templateFilter(boolean dslOnlyMode) {
// Load ILM files only when the server supports ILM i.e. dsl-only-mode is false
return templateName -> dslOnlyMode == false || templateName.endsWith("@ilm") == false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for logs-apm.app if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: logs-apm.app_logs-default_policy
prefer_ilm: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for logs-apm.error if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: logs-apm.error_logs-default_policy
prefer_ilm: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.app if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.app_metrics-default_policy
prefer_ilm: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.internal if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.internal_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions .../main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_destination.10m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_destination_10m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions ...c/main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_destination.1m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_destination_1m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions .../main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_destination.60m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_destination_60m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions .../src/main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_summary.10m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_summary_10m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions ...a/src/main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_summary.1m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_summary_1m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions .../src/main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_summary.60m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_summary_60m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions .../main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_transaction.10m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_transaction_10m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions ...c/main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_transaction.1m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_transaction_1m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions .../main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.service_transaction.60m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.service_transaction_60m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions ...data/src/main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.transaction.10m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.transaction_10m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions ...-data/src/main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.transaction.1m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.transaction_1m_metrics-default_policy
prefer_ilm: false
11 changes: 11 additions & 0 deletions ...data/src/main/resources/component-templates/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for metrics-apm.transaction.60m if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: metrics-apm.transaction_60m_metrics-default_policy
prefer_ilm: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for traces-apm if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: traces-apm.traces-default_policy
prefer_ilm: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for traces-apm.rum if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: traces-apm.rum_traces-default_policy
prefer_ilm: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: ${xpack.apmdata.template.version}
_meta:
description: Fallback to ILM policy for traces-apm.sampled if data stream lifecycle not defined
managed: true
template:
settings:
index:
lifecycle:
name: traces-apm.sampled_traces-default_policy
prefer_ilm: false
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ composed_of:
- apm@settings
- apm-10d@lifecycle
- logs-apm@settings
- logs-apm.app-fallback@ilm
- logs@custom
- logs-apm.app@custom
- ecs@mappings
ignore_missing_component_templates:
- logs@custom
- logs-apm.app@custom
- logs-apm.app-fallback@ilm
template:
settings:
index:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ 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
ignore_missing_component_templates:
- logs@custom
- logs-apm.error@custom
- logs-apm.error-fallback@ilm
template:
mappings:
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ composed_of:
- apm-90d@lifecycle
- metrics-apm@mappings
- metrics-apm@settings
- metrics-apm.app-fallback@ilm
- metrics@custom
- metrics-apm.app@custom
- ecs@mappings
ignore_missing_component_templates:
- metrics@custom
- metrics-apm.app@custom
- metrics-apm.app-fallback@ilm
template:
settings:
index:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ composed_of:
- apm-90d@lifecycle
- metrics-apm@mappings
- metrics-apm@settings
- metrics-apm.internal-fallback@ilm
- metrics@custom
- metrics-apm.internal@custom
- ecs@mappings
ignore_missing_component_templates:
- metrics@custom
- metrics-apm.internal@custom
- metrics-apm.internal-fallback@ilm
template:
settings:
index:
Expand Down
2 changes: 2 additions & 0 deletions ...data/src/main/resources/index-templates/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ 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
ignore_missing_component_templates:
- metrics@custom
- metrics-apm.service_destination.10m@custom
- metrics-apm.service_destination.10m-fallback@ilm
template:
settings:
index:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ 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
ignore_missing_component_templates:
- metrics@custom
- metrics-apm.service_destination.1m@custom
- metrics-apm.service_destination.1m-fallback@ilm
template:
settings:
index:
Expand Down
2 changes: 2 additions & 0 deletions ...data/src/main/resources/index-templates/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ 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
ignore_missing_component_templates:
- metrics@custom
- metrics-apm.service_destination.60m@custom
- metrics-apm.service_destination.60m-fallback@ilm
template:
settings:
index:
Expand Down
Loading

0 comments on commit efdd0c3

Please sign in to comment.