Skip to content

Commit

Permalink
[APM] Update ML job ID in data telemetry tasks
Browse files Browse the repository at this point in the history
Use "apm-*" to match the new job IDs added in elastic#70560.
  • Loading branch information
smith committed Jul 8, 2020
1 parent d43c460 commit 8dbb0aa
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,40 @@ describe('data telemetry collection tasks', () => {
});
});
});

describe('integrations', () => {
const integrationsTask = tasks.find((task) => task.name === 'integrations');

it('returns the count of ML jobs', async () => {
const transportRequest = jest
.fn()
.mockResolvedValueOnce({ data: { count: 1 } });

expect(
await integrationsTask?.executor({ indices, transportRequest } as any)
).toEqual({
integrations: {
ml: {
all_jobs_count: 1,
},
},
});
});

describe('with no data', () => {
it('returns a count of 0', async () => {
const transportRequest = jest.fn().mockResolvedValueOnce({});

expect(
await integrationsTask?.executor({ indices, transportRequest } as any)
).toEqual({
integrations: {
ml: {
all_jobs_count: 0,
},
},
});
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,32 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { flatten, merge, sortBy, sum } from 'lodash';
import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent';
import { TelemetryTask } from '.';
import { AGENT_NAMES } from '../../../../common/agent_name';
import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import {
PROCESSOR_EVENT,
SERVICE_NAME,
AGENT_NAME,
AGENT_VERSION,
CLOUD_AVAILABILITY_ZONE,
CLOUD_PROVIDER,
CLOUD_REGION,
ERROR_GROUP_ID,
TRANSACTION_NAME,
PARENT_ID,
PROCESSOR_EVENT,
SERVICE_FRAMEWORK_NAME,
SERVICE_FRAMEWORK_VERSION,
SERVICE_LANGUAGE_NAME,
SERVICE_LANGUAGE_VERSION,
SERVICE_NAME,
SERVICE_RUNTIME_NAME,
SERVICE_RUNTIME_VERSION,
TRANSACTION_NAME,
USER_AGENT_ORIGINAL,
CLOUD_AVAILABILITY_ZONE,
CLOUD_PROVIDER,
CLOUD_REGION,
} from '../../../../common/elasticsearch_fieldnames';
import { Span } from '../../../../typings/es_schemas/ui/span';
import { APMError } from '../../../../typings/es_schemas/ui/apm_error';
import { TelemetryTask } from '.';
import { AgentName } from '../../../../typings/es_schemas/ui/fields/agent';
import { Span } from '../../../../typings/es_schemas/ui/span';
import { Transaction } from '../../../../typings/es_schemas/ui/transaction';
import { ML_GROUP_NAME_APM } from '../../anomaly_detection/create_anomaly_detection_jobs';
import { APMTelemetry } from '../types';

const TIME_RANGES = ['1d', 'all'] as const;
Expand Down Expand Up @@ -465,11 +466,9 @@ export const tasks: TelemetryTask[] = [
{
name: 'integrations',
executor: async ({ transportRequest }) => {
const apmJobs = ['*-high_mean_response_time'];

const response = (await transportRequest({
method: 'get',
path: `/_ml/anomaly_detectors/${apmJobs.join(',')}`,
path: `/_ml/anomaly_detectors/${ML_GROUP_NAME_APM}-*`,
})) as { data?: { count: number } };

return {
Expand Down

0 comments on commit 8dbb0aa

Please sign in to comment.