Skip to content
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

Large diffs are not rendered by default.

3,742 changes: 2 additions & 3,740 deletions x-pack/solutions/security/plugins/security_solution/server/usage/collector.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,20 @@ describe('Detections Usage and Metrics', () => {
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
query_custom: {
alerts: 800,
cases: 1,
disabled: 1,
enabled: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
response_actions: initialResponseActionsUsage,
has_exceptions: 0,
},
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
SingleEventMetric,
AlertSuppressionUsage,
SpacesUsage,
FeatureTypeUsage,
ResponseActionsUsage,
} from './types';

Expand Down Expand Up @@ -44,136 +45,41 @@ export const getInitialSpacesUsage = (): SpacesUsage => ({
rules_in_spaces: [],
});

export const getInitialFeatureTypeUsage = (): FeatureTypeUsage => ({
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
response_actions: initialResponseActionsUsage,
has_exceptions: 0,
});

/**
* Default detection rule usage count, split by type + elastic/custom
*/
export const getInitialRulesUsage = (): RulesTypeUsage => ({
query: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
threshold: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
eql: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
machine_learning: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
threat_match: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
new_terms: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
esql: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
elastic_total: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
custom_total: {
enabled: 0,
disabled: 0,
alerts: 0,
cases: 0,
legacy_notifications_enabled: 0,
legacy_notifications_disabled: 0,
notifications_enabled: 0,
notifications_disabled: 0,
legacy_investigation_fields: 0,
alert_suppression: initialAlertSuppression,
has_exceptions: 0,
response_actions: initialResponseActionsUsage,
},
query: getInitialFeatureTypeUsage(),
query_custom: getInitialFeatureTypeUsage(),
threshold: getInitialFeatureTypeUsage(),
threshold_custom: getInitialFeatureTypeUsage(),
eql: getInitialFeatureTypeUsage(),
eql_custom: getInitialFeatureTypeUsage(),
machine_learning: getInitialFeatureTypeUsage(),
machine_learning_custom: getInitialFeatureTypeUsage(),
threat_match: getInitialFeatureTypeUsage(),
threat_match_custom: getInitialFeatureTypeUsage(),
new_terms: getInitialFeatureTypeUsage(),
new_terms_custom: getInitialFeatureTypeUsage(),
esql: getInitialFeatureTypeUsage(),
esql_custom: getInitialFeatureTypeUsage(),
elastic_total: getInitialFeatureTypeUsage(),
custom_total: getInitialFeatureTypeUsage(),
});

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { MakeSchemaFrom } from '@kbn/usage-collection-plugin/server';
import { ruleTypeUsageSchema } from './schemas/detection_rule_usage';
import { ruleMetricsSchema } from './schemas/prebuilt_rule_detail';
import { ruleStatusMetricsSchema } from './schemas/detection_rule_status';
import type { RuleAdoption } from './types';

export const rulesMetricsSchema: MakeSchemaFrom<RuleAdoption> = {
spaces_usage: {
total: {
type: 'long',
_meta: { description: 'Total number of spaces where detection rules added' },
},
rules_in_spaces: {
type: 'array',
items: {
type: 'long',
_meta: { description: 'Number of rules is each space' },
},
},
},
detection_rule_usage: ruleTypeUsageSchema,
detection_rule_detail: {
type: 'array',
items: ruleMetricsSchema,
},
detection_rule_status: ruleStatusMetricsSchema,
};
Loading