Skip to content

Commit 8dbb0aa

Browse files
committed
[APM] Update ML job ID in data telemetry tasks
Use "apm-*" to match the new job IDs added in elastic#70560.
1 parent d43c460 commit 8dbb0aa

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,40 @@ describe('data telemetry collection tasks', () => {
6565
});
6666
});
6767
});
68+
69+
describe('integrations', () => {
70+
const integrationsTask = tasks.find((task) => task.name === 'integrations');
71+
72+
it('returns the count of ML jobs', async () => {
73+
const transportRequest = jest
74+
.fn()
75+
.mockResolvedValueOnce({ data: { count: 1 } });
76+
77+
expect(
78+
await integrationsTask?.executor({ indices, transportRequest } as any)
79+
).toEqual({
80+
integrations: {
81+
ml: {
82+
all_jobs_count: 1,
83+
},
84+
},
85+
});
86+
});
87+
88+
describe('with no data', () => {
89+
it('returns a count of 0', async () => {
90+
const transportRequest = jest.fn().mockResolvedValueOnce({});
91+
92+
expect(
93+
await integrationsTask?.executor({ indices, transportRequest } as any)
94+
).toEqual({
95+
integrations: {
96+
ml: {
97+
all_jobs_count: 0,
98+
},
99+
},
100+
});
101+
});
102+
});
103+
});
68104
});

x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,32 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66
import { flatten, merge, sortBy, sum } from 'lodash';
7-
import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent';
7+
import { TelemetryTask } from '.';
88
import { AGENT_NAMES } from '../../../../common/agent_name';
9-
import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
109
import {
11-
PROCESSOR_EVENT,
12-
SERVICE_NAME,
1310
AGENT_NAME,
1411
AGENT_VERSION,
12+
CLOUD_AVAILABILITY_ZONE,
13+
CLOUD_PROVIDER,
14+
CLOUD_REGION,
1515
ERROR_GROUP_ID,
16-
TRANSACTION_NAME,
1716
PARENT_ID,
17+
PROCESSOR_EVENT,
1818
SERVICE_FRAMEWORK_NAME,
1919
SERVICE_FRAMEWORK_VERSION,
2020
SERVICE_LANGUAGE_NAME,
2121
SERVICE_LANGUAGE_VERSION,
22+
SERVICE_NAME,
2223
SERVICE_RUNTIME_NAME,
2324
SERVICE_RUNTIME_VERSION,
25+
TRANSACTION_NAME,
2426
USER_AGENT_ORIGINAL,
25-
CLOUD_AVAILABILITY_ZONE,
26-
CLOUD_PROVIDER,
27-
CLOUD_REGION,
2827
} from '../../../../common/elasticsearch_fieldnames';
29-
import { Span } from '../../../../typings/es_schemas/ui/span';
3028
import { APMError } from '../../../../typings/es_schemas/ui/apm_error';
31-
import { TelemetryTask } from '.';
29+
import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent';
30+
import { Span } from '../../../../typings/es_schemas/ui/span';
31+
import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
32+
import { ML_GROUP_NAME_APM } from '../../anomaly_detection/create_anomaly_detection_jobs';
3233
import { APMTelemetry } from '../types';
3334

3435
const TIME_RANGES = ['1d', 'all'] as const;
@@ -465,11 +466,9 @@ export const tasks: TelemetryTask[] = [
465466
{
466467
name: 'integrations',
467468
executor: async ({ transportRequest }) => {
468-
const apmJobs = ['*-high_mean_response_time'];
469-
470469
const response = (await transportRequest({
471470
method: 'get',
472-
path: `/_ml/anomaly_detectors/${apmJobs.join(',')}`,
471+
path: `/_ml/anomaly_detectors/${ML_GROUP_NAME_APM}-*`,
473472
})) as { data?: { count: number } };
474473

475474
return {

0 commit comments

Comments
 (0)