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] alerts #78933

Merged
merged 5 commits into from
Oct 2, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -3,7 +3,6 @@
"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"
]
}
57 changes: 56 additions & 1 deletion x-pack/plugins/alerts/server/usage/alerts_usage_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,44 @@
* 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 { AlertsUsage } from './types';

const byTypeSchema: MakeSchemaFrom<AlertsUsage>['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 same question as #78832 (comment).

@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?

// 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 alerts (searching the use of the alerts API `registerType`:
// Built-in
'__index-threshold': { type: 'long' },
// APM
apm__error_rate: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
apm__transaction_error_rate: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
apm__transaction_duration: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
apm__transaction_duration_anomaly: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
// Infra
metrics__alert__threshold: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
metrics__alert__inventory__threshold: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
logs__alert__document__count: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
// Monitoring
monitoring_alert_cluster_health: { type: 'long' },
monitoring_alert_cpu_usage: { type: 'long' },
monitoring_alert_disk_usage: { type: 'long' },
monitoring_alert_elasticsearch_version_mismatch: { type: 'long' },
monitoring_alert_kibana_version_mismatch: { type: 'long' },
monitoring_alert_license_expiration: { type: 'long' },
monitoring_alert_logstash_version_mismatch: { type: 'long' },
monitoring_alert_nodes_changed: { type: 'long' },
// Security Solution
siem__signals: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
siem__notifications: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
// Uptime
xpack__uptime__alerts__monitorStatus: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
xpack__uptime__alerts__tls: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
xpack__uptime__alerts__durationAnomaly: { type: 'long' }, // eslint-disable-line @typescript-eslint/naming-convention
};

export function createAlertsUsageCollector(
usageCollection: UsageCollectionSetup,
taskManager: TaskManagerStartContract
Expand Down Expand Up @@ -50,6 +83,28 @@ export function createAlertsUsageCollector(
};
}
},
schema: {
count_total: { type: 'long' },
count_active_total: { type: 'long' },
count_disabled_total: { type: 'long' },
throttle_time: {
min: { type: 'long' },
avg: { type: 'float' },
max: { type: 'long' },
},
schedule_time: {
min: { type: 'long' },
avg: { type: 'float' },
max: { type: 'long' },
},
connectors_per_alert: {
min: { type: 'long' },
avg: { type: 'float' },
max: { type: 'long' },
},
count_active_by_type: byTypeSchema,
count_by_type: byTypeSchema,
},
});
}

Expand Down
192 changes: 192 additions & 0 deletions x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,197 @@
{
"properties": {
"alerts": {
"properties": {
"count_total": {
"type": "long"
},
"count_active_total": {
"type": "long"
},
"count_disabled_total": {
"type": "long"
},
"throttle_time": {
"properties": {
"min": {
"type": "long"
},
"avg": {
"type": "float"
},
"max": {
"type": "long"
}
}
},
"schedule_time": {
"properties": {
"min": {
"type": "long"
},
"avg": {
"type": "float"
},
"max": {
"type": "long"
}
}
},
"connectors_per_alert": {
"properties": {
"min": {
"type": "long"
},
"avg": {
"type": "float"
},
"max": {
"type": "long"
}
}
},
"count_active_by_type": {
"properties": {
"DYNAMIC_KEY": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as comment #78832 (comment)
Having a placeholder for unknowns is a great way to keep track of fields that are probably unmapped right now. If Infra isn't comfortable with filtering out the DYNAMIC_KEY fields, we'll have to take care of that in the diff we provide at FF (i.e. ignore these fields because they can't be mapped in the legacy service indices anyway).

"type": "long"
},
"__index-threshold": {
"type": "long"
},
"apm__error_rate": {
"type": "long"
},
"apm__transaction_error_rate": {
"type": "long"
},
"apm__transaction_duration": {
"type": "long"
},
"apm__transaction_duration_anomaly": {
"type": "long"
},
"metrics__alert__threshold": {
"type": "long"
},
"metrics__alert__inventory__threshold": {
"type": "long"
},
"logs__alert__document__count": {
"type": "long"
},
"monitoring_alert_cluster_health": {
"type": "long"
},
"monitoring_alert_cpu_usage": {
"type": "long"
},
"monitoring_alert_disk_usage": {
"type": "long"
},
"monitoring_alert_elasticsearch_version_mismatch": {
"type": "long"
},
"monitoring_alert_kibana_version_mismatch": {
"type": "long"
},
"monitoring_alert_license_expiration": {
"type": "long"
},
"monitoring_alert_logstash_version_mismatch": {
"type": "long"
},
"monitoring_alert_nodes_changed": {
"type": "long"
},
"siem__signals": {
"type": "long"
},
"siem__notifications": {
"type": "long"
},
"xpack__uptime__alerts__monitorStatus": {
"type": "long"
},
"xpack__uptime__alerts__tls": {
"type": "long"
},
"xpack__uptime__alerts__durationAnomaly": {
"type": "long"
}
}
},
"count_by_type": {
"properties": {
"DYNAMIC_KEY": {
"type": "long"
},
"__index-threshold": {
"type": "long"
},
"apm__error_rate": {
"type": "long"
},
"apm__transaction_error_rate": {
"type": "long"
},
"apm__transaction_duration": {
"type": "long"
},
"apm__transaction_duration_anomaly": {
"type": "long"
},
"metrics__alert__threshold": {
"type": "long"
},
"metrics__alert__inventory__threshold": {
"type": "long"
},
"logs__alert__document__count": {
"type": "long"
},
"monitoring_alert_cluster_health": {
"type": "long"
},
"monitoring_alert_cpu_usage": {
"type": "long"
},
"monitoring_alert_disk_usage": {
"type": "long"
},
"monitoring_alert_elasticsearch_version_mismatch": {
"type": "long"
},
"monitoring_alert_kibana_version_mismatch": {
"type": "long"
},
"monitoring_alert_license_expiration": {
"type": "long"
},
"monitoring_alert_logstash_version_mismatch": {
"type": "long"
},
"monitoring_alert_nodes_changed": {
"type": "long"
},
"siem__signals": {
"type": "long"
},
"siem__notifications": {
"type": "long"
},
"xpack__uptime__alerts__monitorStatus": {
"type": "long"
},
"xpack__uptime__alerts__tls": {
"type": "long"
},
"xpack__uptime__alerts__durationAnomaly": {
"type": "long"
}
}
}
}
},
"canvas": {
"properties": {
"workpads": {
Expand Down