Skip to content

Commit

Permalink
Merge branch 'master' into user-allowlist-artifacts-pt3
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jul 9, 2020
2 parents 50b49a5 + 1f5a1fe commit 046f271
Show file tree
Hide file tree
Showing 2 changed files with 49 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({ body: { 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,31 @@
* 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 { APMTelemetry } from '../types';

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

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

return {
integrations: {
ml: {
all_jobs_count: response.data?.count ?? 0,
all_jobs_count: response.body?.count ?? 0,
},
},
};
Expand Down

0 comments on commit 046f271

Please sign in to comment.