Skip to content

Commit

Permalink
Collect new alerting telemetry data from Kibana index (#139901)
Browse files Browse the repository at this point in the history
* Collect new alerting telemetry data from kibana index count_rules_by_execution_status, count_rules_with_tags, count_rules_by_notify_when, count_rules_snoozed, count_rules_muted, count_rules_with_muted_alerts
  • Loading branch information
ersin-erdal authored Sep 19, 2022
1 parent cd52a2e commit e90ab44
Show file tree
Hide file tree
Showing 12 changed files with 524 additions and 0 deletions.
34 changes: 34 additions & 0 deletions x-pack/plugins/alerting/server/usage/alerting_usage_collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ const byTaskStatusSchemaByType: MakeSchemaFrom<AlertingUsage>['count_failed_and_
unrecognized: byTypeSchema,
};

const byStatusSchema: MakeSchemaFrom<AlertingUsage>['count_rules_by_execution_status'] = {
success: { type: 'long' },
error: { type: 'long' },
warning: { type: 'long' },
};

const byNotifyWhenSchema: MakeSchemaFrom<AlertingUsage>['count_rules_by_notify_when'] = {
on_action_group_change: { type: 'long' },
on_active_alert: { type: 'long' },
on_throttle_interval: { type: 'long' },
};

export function createAlertingUsageCollector(
usageCollection: UsageCollectionSetup,
taskManager: Promise<TaskManagerStartContract>
Expand Down Expand Up @@ -173,6 +185,21 @@ export function createAlertingUsageCollector(
count_failed_and_unrecognized_rule_tasks_per_day: 0,
count_failed_and_unrecognized_rule_tasks_by_status_per_day: {},
count_failed_and_unrecognized_rule_tasks_by_status_by_type_per_day: {},
count_rules_by_execution_status: {
success: 0,
warning: 0,
error: 0,
},
count_rules_by_notify_when: {
on_action_group_change: 0,
on_active_alert: 0,
on_throttle_interval: 0,
},
count_rules_with_tags: 0,
count_rules_snoozed: 0,
count_rules_muted: 0,
count_rules_with_muted_alerts: 0,
count_connector_types_by_consumers: {},
avg_execution_time_per_day: 0,
avg_execution_time_by_type_per_day: {},
avg_es_search_duration_per_day: 0,
Expand Down Expand Up @@ -249,6 +276,13 @@ export function createAlertingUsageCollector(
count_failed_and_unrecognized_rule_tasks_per_day: { type: 'long' },
count_failed_and_unrecognized_rule_tasks_by_status_per_day: byTaskStatusSchema,
count_failed_and_unrecognized_rule_tasks_by_status_by_type_per_day: byTaskStatusSchemaByType,
count_rules_by_execution_status: byStatusSchema,
count_rules_with_tags: { type: 'long' },
count_rules_by_notify_when: byNotifyWhenSchema,
count_rules_snoozed: { type: 'long' },
count_rules_muted: { type: 'long' },
count_rules_with_muted_alerts: { type: 'long' },
count_connector_types_by_consumers: { DYNAMIC_KEY: { DYNAMIC_KEY: { type: 'long' } } },
avg_execution_time_per_day: { type: 'long' },
avg_execution_time_by_type_per_day: byTypeSchema,
avg_es_search_duration_per_day: { type: 'long' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,90 @@ describe('kibana index telemetry', () => {
},
],
},
by_execution_status: {
doc_count_error_upper_bound: 0,
sum_other_doc_count: 0,
buckets: [
{
key: 'unknown',
doc_count: 0,
},
{
key: 'ok',
doc_count: 1,
},
{
key: 'active',
doc_count: 2,
},
{
key: 'pending',
doc_count: 3,
},
{
key: 'error',
doc_count: 4,
},
{
key: 'warning',
doc_count: 5,
},
],
},
by_notify_when: {
doc_count_error_upper_bound: 0,
sum_other_doc_count: 0,
buckets: [
{
key: 'onActionGroupChange',
doc_count: 5,
},
{
key: 'onActiveAlert',
doc_count: 6,
},
{
key: 'onThrottleInterval',
doc_count: 7,
},
],
},
connector_types_by_consumers: {
doc_count_error_upper_bound: 0,
sum_other_doc_count: 0,
buckets: [
{
key: 'alerts',
actions: {
connector_types: {
buckets: [
{
key: '.server-log',
doc_count: 2,
},
{
key: '.email',
doc_count: 3,
},
],
},
},
},
{
key: 'siem',
actions: {
connector_types: {
buckets: [
{
key: '.index',
doc_count: 4,
},
],
},
},
},
],
},
max_throttle_time: { value: 60 },
min_throttle_time: { value: 0 },
avg_throttle_time: { value: 30 },
Expand All @@ -64,6 +148,10 @@ describe('kibana index telemetry', () => {
max_actions_count: { value: 4 },
min_actions_count: { value: 0 },
avg_actions_count: { value: 2.5 },
sum_rules_with_tags: { value: 10 },
sum_rules_snoozed: { value: 11 },
sum_rules_muted: { value: 12 },
sum_rules_with_muted_alerts: { value: 13 },
},
});

Expand Down Expand Up @@ -109,6 +197,29 @@ describe('kibana index telemetry', () => {
max: 60,
min: 0,
},
count_rules_by_execution_status: {
success: 3,
error: 4,
warning: 5,
},
count_rules_with_tags: 10,
count_rules_by_notify_when: {
on_action_group_change: 5,
on_active_alert: 6,
on_throttle_interval: 7,
},
count_rules_snoozed: 11,
count_rules_muted: 12,
count_rules_with_muted_alerts: 13,
count_connector_types_by_consumers: {
alerts: {
__email: 3,
'__server-log': 2,
},
siem: {
__index: 4,
},
},
});
});

Expand Down Expand Up @@ -138,6 +249,20 @@ describe('kibana index telemetry', () => {
min: 0,
},
count_by_type: {},
count_rules_by_execution_status: {
success: 0,
error: 0,
warning: 0,
},
count_rules_with_tags: 0,
count_rules_by_notify_when: {
on_action_group_change: 0,
on_active_alert: 0,
on_throttle_interval: 0,
},
count_rules_snoozed: 0,
count_rules_muted: 0,
count_rules_with_muted_alerts: 0,
count_total: 0,
schedule_time: {
avg: '0s',
Expand All @@ -159,6 +284,7 @@ describe('kibana index telemetry', () => {
max: 0,
min: 0,
},
count_connector_types_by_consumers: {},
});
});
});
Expand Down
Loading

0 comments on commit e90ab44

Please sign in to comment.