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

[plugin/apm-data]Fallback to ILM for non-dsl-only mode if DSL unavailable #112759

Merged
merged 17 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,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, 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)
lahsivjar marked this conversation as resolved.
Show resolved Hide resolved
);
clusterService.setNodeConnectionsService(createNoOpNodeConnectionsService());
ClusterState initialClusterState = ClusterState.builder(new ClusterName(ClusterServiceUtils.class.getSimpleName()))
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
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
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
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
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
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