|
4 | 4 | * you may not use this file except in compliance with the Elastic License. |
5 | 5 | */ |
6 | 6 |
|
7 | | -import { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; |
| 7 | +import { MakeSchemaFrom, UsageCollectionSetup } from 'src/plugins/usage_collection/server'; |
8 | 8 | import { get } from 'lodash'; |
9 | 9 | import { TaskManagerStartContract } from '../../../task_manager/server'; |
10 | 10 | import { ActionsUsage } from './types'; |
11 | 11 |
|
| 12 | +const byTypeSchema: MakeSchemaFrom<ActionsUsage>['count_by_type'] = { |
| 13 | + // TODO: Find out an automated way to populate the keys or reformat these into an array (and change the Remote Telemetry indexer accordingly) |
| 14 | + DYNAMIC_KEY: { type: 'long' }, |
| 15 | + // Known actions: |
| 16 | + __email: { type: 'long' }, |
| 17 | + __index: { type: 'long' }, |
| 18 | + __pagerduty: { type: 'long' }, |
| 19 | + '__server-log': { type: 'long' }, |
| 20 | + __slack: { type: 'long' }, |
| 21 | + __webhook: { type: 'long' }, |
| 22 | + __servicenow: { type: 'long' }, |
| 23 | + __jira: { type: 'long' }, |
| 24 | + __resilient: { type: 'long' }, |
| 25 | +}; |
| 26 | + |
12 | 27 | export function createActionsUsageCollector( |
13 | 28 | usageCollection: UsageCollectionSetup, |
14 | 29 | taskManager: TaskManagerStartContract |
15 | 30 | ) { |
16 | 31 | return usageCollection.makeUsageCollector<ActionsUsage>({ |
17 | 32 | type: 'actions', |
18 | 33 | isReady: () => true, |
| 34 | + schema: { |
| 35 | + count_total: { type: 'long' }, |
| 36 | + count_active_total: { type: 'long' }, |
| 37 | + count_by_type: byTypeSchema, |
| 38 | + count_active_by_type: byTypeSchema, |
| 39 | + }, |
19 | 40 | fetch: async () => { |
20 | 41 | try { |
21 | 42 | const doc = await getLatestTaskState(await taskManager); |
|
0 commit comments