Skip to content

Commit

Permalink
[Usage Collection] [schema] actions (#78832)
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo authored Oct 2, 2020
1 parent 46af5fc commit f398b49
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 2 deletions.
1 change: 0 additions & 1 deletion x-pack/.telemetryrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
Expand Down
23 changes: 22 additions & 1 deletion x-pack/plugins/actions/server/usage/actions_usage_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,39 @@
* 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
) {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit f398b49

Please sign in to comment.