Skip to content

Commit 014dce0

Browse files
authored
[APM] Update ML job ID in data telemetry tasks (#71044) (#71185)
Use "apm-*" to match the new job IDs added in #70560.
1 parent 6050120 commit 014dce0

File tree

2 files changed

+49
-13
lines changed

2 files changed

+49
-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({ body: { 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: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
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';
3232
import { APMTelemetry } from '../types';
3333

3434
const TIME_RANGES = ['1d', 'all'] as const;
@@ -465,17 +465,17 @@ export const tasks: TelemetryTask[] = [
465465
{
466466
name: 'integrations',
467467
executor: async ({ transportRequest }) => {
468-
const apmJobs = ['*-high_mean_response_time'];
468+
const apmJobs = ['apm-*', '*-high_mean_response_time'];
469469

470470
const response = (await transportRequest({
471471
method: 'get',
472472
path: `/_ml/anomaly_detectors/${apmJobs.join(',')}`,
473-
})) as { data?: { count: number } };
473+
})) as { body?: { count: number } };
474474

475475
return {
476476
integrations: {
477477
ml: {
478-
all_jobs_count: response.data?.count ?? 0,
478+
all_jobs_count: response.body?.count ?? 0,
479479
},
480480
},
481481
};

0 commit comments

Comments
 (0)