Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Usage Collection] [schema] actions #78832

Merged
merged 3 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
"plugins/maps/server/maps_telemetry/collectors/register.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'] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mindbat did you want the alerting team to keep updating this list on each release when new actions exist? or will it be possible with the DYNAMIC_KEY to automatically handle new types of actions per release on your end?

Copy link

@mindbat mindbat Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little fuzzy on the code here (not a ts dev 😅 ), but it's my understanding that @afharo's DYNAMIC_KEY in the schema that gets handed off to my team will be enough for us to know "this key's value will have this type, but its name might change"

// 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