mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[APM] Collect total number of service groups (#142768)
* [APM] Collect the total number of service groups * Add unit tests * Update telemetry mapping * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * update snapshots Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
4b7df3cb36
commit
4197c03bb6
6 changed files with 57 additions and 1 deletions
|
@ -1075,6 +1075,9 @@ exports[`APM telemetry helpers getApmTelemetry generates a JSON object with the
|
|||
"properties": {
|
||||
"kuery_fields": {
|
||||
"type": "keyword"
|
||||
},
|
||||
"total": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { savedObjectsClientMock } from '@kbn/core-saved-objects-api-server-mocks';
|
||||
import { ApmIndicesConfig } from '../../../routes/settings/apm_indices/get_apm_indices';
|
||||
import { tasks } from './tasks';
|
||||
import {
|
||||
|
@ -444,4 +445,49 @@ describe('data telemetry collection tasks', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('service groups', () => {
|
||||
const task = tasks.find((t) => t.name === 'service_groups');
|
||||
const savedObjectsClient = savedObjectsClientMock.create();
|
||||
|
||||
savedObjectsClient.find.mockResolvedValue({
|
||||
page: 1,
|
||||
per_page: 500,
|
||||
total: 2,
|
||||
saved_objects: [
|
||||
{
|
||||
type: 'apm-service-group',
|
||||
id: '0b6157f0-44bd-11ed-bdb7-bffab551cd4d',
|
||||
namespaces: ['default'],
|
||||
attributes: {
|
||||
color: '#5094C4',
|
||||
kuery: 'service.environment: production',
|
||||
groupName: 'production',
|
||||
},
|
||||
references: [],
|
||||
score: 1,
|
||||
},
|
||||
{
|
||||
type: 'apm-service-group',
|
||||
id: '0b6157f0-44bd-11ed-bdb7-bffab551cd4d',
|
||||
namespaces: ['default'],
|
||||
attributes: {
|
||||
color: '#5094C4',
|
||||
kuery: 'agent.name: go',
|
||||
groupName: 'agent',
|
||||
},
|
||||
references: [],
|
||||
score: 0,
|
||||
},
|
||||
],
|
||||
});
|
||||
it('returns service group stats', async () => {
|
||||
expect(await task?.executor({ savedObjectsClient } as any)).toEqual({
|
||||
service_groups: {
|
||||
kuery_fields: ['service.environment', 'agent.name'],
|
||||
total: 2,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,6 +15,7 @@ import { AGENT_NAMES, RUM_AGENT_NAMES } from '../../../../common/agent_name';
|
|||
import {
|
||||
SavedServiceGroup,
|
||||
APM_SERVICE_GROUP_SAVED_OBJECT_TYPE,
|
||||
MAX_NUMBER_OF_SERVICE_GROUPS,
|
||||
} from '../../../../common/service_groups';
|
||||
import { getKueryFields } from '../../helpers/get_kuery_fields';
|
||||
import {
|
||||
|
@ -1134,7 +1135,7 @@ export const tasks: TelemetryTask[] = [
|
|||
const response = await savedObjectsClient.find<SavedServiceGroup>({
|
||||
type: APM_SERVICE_GROUP_SAVED_OBJECT_TYPE,
|
||||
page: 1,
|
||||
perPage: 50,
|
||||
perPage: MAX_NUMBER_OF_SERVICE_GROUPS,
|
||||
sortField: 'updated_at',
|
||||
sortOrder: 'desc',
|
||||
});
|
||||
|
@ -1148,6 +1149,7 @@ export const tasks: TelemetryTask[] = [
|
|||
return {
|
||||
service_groups: {
|
||||
kuery_fields: kueryFields,
|
||||
total: response.total ?? 0,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
|
|
@ -235,6 +235,7 @@ export const apmSchema: MakeSchemaFrom<APMUsage> = {
|
|||
},
|
||||
service_groups: {
|
||||
kuery_fields: { type: 'array', items: { type: 'keyword' } },
|
||||
total: long,
|
||||
},
|
||||
per_service: { type: 'array', items: { ...apmPerServiceSchema } },
|
||||
tasks: {
|
||||
|
|
|
@ -173,6 +173,7 @@ export interface APMUsage {
|
|||
};
|
||||
service_groups: {
|
||||
kuery_fields: string[];
|
||||
total: number;
|
||||
};
|
||||
per_service: APMPerService[];
|
||||
tasks: Record<
|
||||
|
|
|
@ -4109,6 +4109,9 @@
|
|||
"items": {
|
||||
"type": "keyword"
|
||||
}
|
||||
},
|
||||
"total": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue