Skip to content

Commit 5456472

Browse files
authored
[Fleet] Add modified_ilms telemetry to fleet_usages (#243637)
## Summary Relates elastic/ingest-dev#6085 Add `modified_ilms` to `fleet_usages` telemetry to track how many clusters have these ILM modified by users. To verify: - modify one of the ILMs e.g. synthetics - wait for the fleet usage sender to run (hourly schedule) - check that `modified_ilms` array has `synthetics` in it ``` [2025-11-20T13:44:01.394+01:00][DEBUG][plugins.fleet] Fleet usage telemetry: {"agents_enabled":true,...,"modified_ilms":["synthetics"]} ``` ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [ ] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. ### Identify risks Does this PR introduce any risks? For example, consider risks like hard to test bugs, performance regression, potential of data loss. Describe the risk, its severity, and mitigation for each identified risk. Invite stakeholders and evaluate how to proceed before merging. - [ ] [See some risk examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) - [ ] ...
1 parent 0091cc7 commit 5456472

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { getModifiedILMs } from './modified_ilms';
9+
10+
jest.mock('../services/epm/elasticsearch/template/default_settings', () => {
11+
return {
12+
getILMPolicies: jest.fn().mockResolvedValue(
13+
new Map([
14+
['logs', { deprecatedILMPolicy: { version: 2 }, newILMPolicy: { version: 1 } }],
15+
['metrics', { deprecatedILMPolicy: { version: 1 }, newILMPolicy: { version: 3 } }],
16+
['synthetics', { deprecatedILMPolicy: { version: 2 }, newILMPolicy: { version: 1 } }],
17+
])
18+
),
19+
};
20+
});
21+
22+
describe('getModifiedILMs', () => {
23+
it('should return an array of modified ILM policy names', async () => {
24+
const modifiedILMs = await getModifiedILMs();
25+
expect(modifiedILMs).toEqual(['logs', 'metrics@lifecycle', 'synthetics']);
26+
});
27+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { appContextService } from '../services';
9+
import { getILMPolicies } from '../services/epm/elasticsearch/template/default_settings';
10+
11+
export async function getModifiedILMs(): Promise<string[]> {
12+
const isILMPolicyDisabled = appContextService.getConfig()?.internal?.disableILMPolicies ?? false;
13+
if (isILMPolicyDisabled) {
14+
return [];
15+
}
16+
const dataStreamTypes = ['logs', 'metrics', 'synthetics'];
17+
const ilmPolicies = await getILMPolicies(dataStreamTypes);
18+
const modifiedILMs: string[] = [];
19+
20+
ilmPolicies.forEach((policies, dataStreamType) => {
21+
const { deprecatedILMPolicy, newILMPolicy } = policies;
22+
if ((deprecatedILMPolicy?.version ?? 1) > 1) {
23+
modifiedILMs.push(dataStreamType);
24+
}
25+
if ((newILMPolicy?.version ?? 1) > 1) {
26+
modifiedILMs.push(`${dataStreamType}@lifecycle`);
27+
}
28+
});
29+
return modifiedILMs;
30+
}

x-pack/platform/plugins/shared/fleet/server/collectors/register.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import type { AgentsPerOutputType } from './agents_per_output';
2828
import { getAgentsPerOutput } from './agents_per_output';
2929
import type { IntegrationsDetails } from './integrations_collector';
3030
import { getIntegrationsDetails } from './integrations_collector';
31+
import { getModifiedILMs } from './modified_ilms';
3132

3233
export interface Usage {
3334
agents_enabled: boolean;
@@ -50,6 +51,7 @@ export interface FleetUsage extends Usage, AgentData {
5051
fleet_server_logs_top_errors?: string[];
5152
agents_per_output_type: AgentsPerOutputType[];
5253
integrations_details: IntegrationsDetails[];
54+
modified_ilms: string[];
5355
}
5456

5557
export const fetchFleetUsage = async (
@@ -77,6 +79,7 @@ export const fetchFleetUsage = async (
7779
deployment_id: appContextService.getCloud()?.deploymentId,
7880
integrations_details: await getIntegrationsDetails(soClient),
7981
agentless_agents: await getAgentUsage(soClient, esClient, true),
82+
modified_ilms: await getModifiedILMs(),
8083
};
8184
return usage;
8285
};

x-pack/platform/plugins/shared/fleet/server/services/telemetry/fleet_usages_schema.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,13 @@ export const fleetUsagesSchema: RootSchema<any> = {
517517
type: 'keyword',
518518
_meta: { description: 'id of the deployment', optional: true },
519519
},
520+
modified_ilms: {
521+
type: 'array',
522+
items: {
523+
type: 'keyword',
524+
_meta: { description: 'list of managed ILMs modified by users' },
525+
},
526+
},
520527
};
521528

522529
export const fleetIntegrationsSchema: RootSchema<any> = {

0 commit comments

Comments
 (0)