[Usage Collection] [schema] actions (#78832)

This commit is contained in:
Alejandro Fernández Haro 2020-10-02 16:03:42 +01:00 committed by GitHub
parent 46af5fcc2d
commit f398b49200
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 100 additions and 2 deletions

View file

@ -2,7 +2,6 @@
"output": "plugins/telemetry_collection_xpack/schema/xpack_plugins.json",
"root": "plugins/",
"exclude": [
"plugins/actions/server/usage/actions_usage_collector.ts",
"plugins/alerts/server/usage/alerts_usage_collector.ts",
"plugins/apm/server/lib/apm_telemetry/index.ts"
]

View file

@ -4,11 +4,26 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { MakeSchemaFrom, UsageCollectionSetup } from 'src/plugins/usage_collection/server';
import { get } from 'lodash';
import { TaskManagerStartContract } from '../../../task_manager/server';
import { ActionsUsage } from './types';
const byTypeSchema: MakeSchemaFrom<ActionsUsage>['count_by_type'] = {
// TODO: Find out an automated way to populate the keys or reformat these into an array (and change the Remote Telemetry indexer accordingly)
DYNAMIC_KEY: { type: 'long' },
// Known actions:
__email: { type: 'long' },
__index: { type: 'long' },
__pagerduty: { type: 'long' },
'__server-log': { type: 'long' },
__slack: { type: 'long' },
__webhook: { type: 'long' },
__servicenow: { type: 'long' },
__jira: { type: 'long' },
__resilient: { type: 'long' },
};
export function createActionsUsageCollector(
usageCollection: UsageCollectionSetup,
taskManager: TaskManagerStartContract
@ -16,6 +31,12 @@ export function createActionsUsageCollector(
return usageCollection.makeUsageCollector<ActionsUsage>({
type: 'actions',
isReady: () => true,
schema: {
count_total: { type: 'long' },
count_active_total: { type: 'long' },
count_by_type: byTypeSchema,
count_active_by_type: byTypeSchema,
},
fetch: async () => {
try {
const doc = await getLatestTaskState(await taskManager);

View file

@ -1,5 +1,83 @@
{
"properties": {
"actions": {
"properties": {
"count_total": {
"type": "long"
},
"count_active_total": {
"type": "long"
},
"count_by_type": {
"properties": {
"DYNAMIC_KEY": {
"type": "long"
},
"__email": {
"type": "long"
},
"__index": {
"type": "long"
},
"__pagerduty": {
"type": "long"
},
"__server-log": {
"type": "long"
},
"__slack": {
"type": "long"
},
"__webhook": {
"type": "long"
},
"__servicenow": {
"type": "long"
},
"__jira": {
"type": "long"
},
"__resilient": {
"type": "long"
}
}
},
"count_active_by_type": {
"properties": {
"DYNAMIC_KEY": {
"type": "long"
},
"__email": {
"type": "long"
},
"__index": {
"type": "long"
},
"__pagerduty": {
"type": "long"
},
"__server-log": {
"type": "long"
},
"__slack": {
"type": "long"
},
"__webhook": {
"type": "long"
},
"__servicenow": {
"type": "long"
},
"__jira": {
"type": "long"
},
"__resilient": {
"type": "long"
}
}
}
}
},
"canvas": {
"properties": {
"workpads": {