From e666f07d06902b4ee5883803081b036829c99503 Mon Sep 17 00:00:00 2001 From: Georgii Gorbachev Date: Fri, 15 Sep 2023 18:25:16 +0200 Subject: [PATCH] Clean up --- .../model/cluster_health.mock.ts | 6 +-- .../model/cluster_health.ts | 16 +++---- .../model/health_stats.mock.ts | 17 +++---- .../model/health_stats.ts | 47 +++++++------------ .../model/rule_health.mock.ts | 6 +-- .../model/rule_health.ts | 16 +++---- .../model/space_health.mock.ts | 6 +-- .../model/space_health.ts | 16 +++---- .../get_cluster_health_route.ts | 2 +- .../get_rule_health/get_rule_health_route.ts | 2 +- .../get_space_health_route.ts | 2 +- .../detection_engine_health_client.ts | 6 +-- .../aggregations/health_stats_for_rule.ts | 8 ++-- .../aggregations/rule_execution_stats.ts | 4 +- .../event_log/event_log_health_client.ts | 6 +-- .../aggregations/health_stats_for_cluster.ts | 4 +- .../aggregations/health_stats_for_space.ts | 4 +- .../rule_objects/aggregations/rule_stats.ts | 6 ++- .../rule_objects_health_client.ts | 12 ++--- 19 files changed, 85 insertions(+), 101 deletions(-) diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/cluster_health.mock.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/cluster_health.mock.ts index 17f7f6dc6a57a..6fac9e9b38521 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/cluster_health.mock.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/cluster_health.mock.ts @@ -10,13 +10,13 @@ import { healthStatsMock } from './health_stats.mock'; const getEmptyClusterHealthSnapshot = (): ClusterHealthSnapshot => { return { - stats_at_the_moment: healthStatsMock.getEmptyRuleStats(), - stats_over_interval: healthStatsMock.getEmptyRuleExecutionStats(), + state_at_the_moment: healthStatsMock.getEmptyHealthOverviewState(), + stats_over_interval: healthStatsMock.getEmptyHealthOverviewStats(), history_over_interval: { buckets: [ { timestamp: '2023-05-15T16:12:14.967Z', - stats: healthStatsMock.getEmptyRuleExecutionStats(), + stats: healthStatsMock.getEmptyHealthOverviewStats(), }, ], }, diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/cluster_health.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/cluster_health.ts index 8d7c83bebdffb..bbf838a828dfe 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/cluster_health.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/cluster_health.ts @@ -6,7 +6,7 @@ */ import type { HealthParameters, HealthSnapshot } from './health_metadata'; -import type { RuleExecutionStats, RuleStats, StatsHistory } from './health_stats'; +import type { HealthOverviewStats, HealthOverviewState, HealthHistory } from './health_stats'; /** * Health calculation parameters for the whole cluster. @@ -18,27 +18,27 @@ export type ClusterHealthParameters = HealthParameters; */ export interface ClusterHealthSnapshot extends HealthSnapshot { /** - * Health stats at the moment of the calculation request. + * Health state at the moment of the calculation request. */ - stats_at_the_moment: ClusterHealthStatsAtTheMoment; + state_at_the_moment: ClusterHealthState; /** * Health stats calculated over the interval specified in the health parameters. */ - stats_over_interval: ClusterHealthStatsOverInterval; + stats_over_interval: ClusterHealthStats; /** * History of change of the same health stats during the interval. */ - history_over_interval: StatsHistory; + history_over_interval: HealthHistory; } /** - * Health stats at the moment of the calculation request. + * Health state at the moment of the calculation request. */ -export type ClusterHealthStatsAtTheMoment = RuleStats; +export type ClusterHealthState = HealthOverviewState; /** * Health stats calculated over a given interval. */ -export type ClusterHealthStatsOverInterval = RuleExecutionStats; +export type ClusterHealthStats = HealthOverviewStats; diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/health_stats.mock.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/health_stats.mock.ts index 545a1b0ef0440..ffb9275bdd89a 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/health_stats.mock.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/health_stats.mock.ts @@ -7,12 +7,12 @@ import type { AggregatedMetric, - RuleExecutionStats, - RuleStats, + HealthOverviewStats, + HealthOverviewState, TotalEnabledDisabled, } from './health_stats'; -const getEmptyRuleStats = (): RuleStats => { +const getEmptyHealthOverviewState = (): HealthOverviewState => { return { number_of_rules: { all: getZeroTotalEnabledDisabled(), @@ -34,7 +34,7 @@ const getZeroTotalEnabledDisabled = (): TotalEnabledDisabled => { }; }; -const getEmptyRuleExecutionStats = (): RuleExecutionStats => { +const getEmptyHealthOverviewStats = (): HealthOverviewStats => { return { number_of_executions: { total: 0, @@ -70,18 +70,15 @@ const getEmptyRuleExecutionStats = (): RuleExecutionStats => { const getZeroAggregatedMetric = (): AggregatedMetric => { return { percentiles: { - '1.0': 0, - '5.0': 0, - '25.0': 0, '50.0': 0, - '75.0': 0, '95.0': 0, '99.0': 0, + '99.9': 0, }, }; }; export const healthStatsMock = { - getEmptyRuleStats, - getEmptyRuleExecutionStats, + getEmptyHealthOverviewState, + getEmptyHealthOverviewStats, }; diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/health_stats.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/health_stats.ts index 4af7ea8c6bd07..3098b3c69c4a3 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/health_stats.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/health_stats.ts @@ -10,7 +10,7 @@ import type { RuleLastRunOutcomes } from '@kbn/alerting-plugin/common'; import type { LogLevel } from '../../model'; // ------------------------------------------------------------------------------------------------- -// Stats history (date histogram) +// History of health stats (date histogram) /** * History of change of a set of stats over a time interval. The interval is split into discreet buckets, @@ -19,14 +19,14 @@ import type { LogLevel } from '../../model'; * This model corresponds to the `date_histogram` aggregation of Elasticsearch: * https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html */ -export interface StatsHistory { - buckets: Array>; +export interface HealthHistory { + buckets: Array>; } /** * Sub-interval with stats calculated over it. */ -export interface StatsBucket { +export interface HealthBucket { /** * Start timestamp of the sub-interval. */ @@ -39,23 +39,15 @@ export interface StatsBucket { } // ------------------------------------------------------------------------------------------------- -// Rule stats - -// TODO: https://github.com/elastic/kibana/issues/125642 Add more stats, such as: -// - number of Kibana instances -// - number of Kibana spaces -// - number of rules with exceptions -// - number of rules with notification actions (total, normal, legacy) -// - number of rules with response actions -// - top X last failed status messages + rule ids for each status -// - top X last partial failure status messages + rule ids for each status -// - top X slowest rules by any metrics (last total execution time, search time, indexing time, etc) -// - top X rules with the largest schedule delay (drift) +// Health overview state + +// TODO: https://github.com/elastic/kibana/issues/125642 Add more data, see health_data.md /** - * "Static" stats calculated for a set of rules, such as number of enabled and disabled rules, etc. + * "Static" health state at the moment of the API call. Calculated for a set of rules. + * Example: number of enabled and disabled rules. */ -export interface RuleStats { +export interface HealthOverviewState { /** * Various counts of different rules. */ @@ -108,19 +100,15 @@ export interface TotalEnabledDisabled { } // ------------------------------------------------------------------------------------------------- -// Rule execution stats +// Health overview stats -// TODO: https://github.com/elastic/kibana/issues/125642 Add more stats, such as: -// - number of detected alerts (source event "hits") -// - number of created alerts (those we wrote to the .alerts-* index) -// - number of times rule hit cirquit breaker, number of not created alerts because of that -// - number of triggered actions -// - top gaps +// TODO: https://github.com/elastic/kibana/issues/125642 Add more data, see health_data.md /** - * "Dynamic" rule execution stats. Can be calculated either for a set of rules or for a single rule. + * "Dynamic" health stats over a specified "health interval". Can be calculated either + * for a set of rules or for a single rule. */ -export interface RuleExecutionStats { +export interface HealthOverviewStats { /** * Number of rule executions. */ @@ -242,13 +230,10 @@ export interface AggregatedMetric { * Distribution of values of an aggregated metric represented by a set of discreet percentiles. * @example * { - * '1.0': 27, - * '5.0': 150, - * '25.0': 240, * '50.0': 420, - * '75.0': 700, * '95.0': 2500, * '99.0': 7800, + * '99.9': 10000, * } */ export type Percentiles = Record; diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/rule_health.mock.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/rule_health.mock.ts index 961a057b2603e..50cb91cf202c5 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/rule_health.mock.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/rule_health.mock.ts @@ -11,15 +11,15 @@ import type { RuleHealthSnapshot } from './rule_health'; const getEmptyRuleHealthSnapshot = (): RuleHealthSnapshot => { return { - stats_at_the_moment: { + state_at_the_moment: { rule: getRulesSchemaMock(), }, - stats_over_interval: healthStatsMock.getEmptyRuleExecutionStats(), + stats_over_interval: healthStatsMock.getEmptyHealthOverviewStats(), history_over_interval: { buckets: [ { timestamp: '2023-05-15T16:12:14.967Z', - stats: healthStatsMock.getEmptyRuleExecutionStats(), + stats: healthStatsMock.getEmptyHealthOverviewStats(), }, ], }, diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/rule_health.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/rule_health.ts index 59756df926e27..77471270695bb 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/rule_health.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/rule_health.ts @@ -7,7 +7,7 @@ import type { RuleResponse } from '../../../model'; import type { HealthParameters, HealthSnapshot } from './health_metadata'; -import type { RuleExecutionStats, StatsHistory } from './health_stats'; +import type { HealthOverviewStats, HealthHistory } from './health_stats'; /** * Health calculation parameters for a given rule. @@ -24,25 +24,25 @@ export interface RuleHealthParameters extends HealthParameters { */ export interface RuleHealthSnapshot extends HealthSnapshot { /** - * Health stats at the moment of the calculation request. + * Health state at the moment of the calculation request. */ - stats_at_the_moment: RuleHealthStatsAtTheMoment; + state_at_the_moment: RuleHealthState; /** * Health stats calculated over the interval specified in the health parameters. */ - stats_over_interval: RuleHealthStatsOverInterval; + stats_over_interval: RuleHealthStats; /** * History of change of the same health stats during the interval. */ - history_over_interval: StatsHistory; + history_over_interval: HealthHistory; } /** - * Health stats at the moment of the calculation request. + * Health state at the moment of the calculation request. */ -export interface RuleHealthStatsAtTheMoment { +export interface RuleHealthState { /** * Rule object including its current execution summary. */ @@ -52,4 +52,4 @@ export interface RuleHealthStatsAtTheMoment { /** * Health stats calculated over a given interval. */ -export type RuleHealthStatsOverInterval = RuleExecutionStats; +export type RuleHealthStats = HealthOverviewStats; diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/space_health.mock.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/space_health.mock.ts index 60e1514cee59e..e445a275d6a8c 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/space_health.mock.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/space_health.mock.ts @@ -10,13 +10,13 @@ import type { SpaceHealthSnapshot } from './space_health'; const getEmptySpaceHealthSnapshot = (): SpaceHealthSnapshot => { return { - stats_at_the_moment: healthStatsMock.getEmptyRuleStats(), - stats_over_interval: healthStatsMock.getEmptyRuleExecutionStats(), + state_at_the_moment: healthStatsMock.getEmptyHealthOverviewState(), + stats_over_interval: healthStatsMock.getEmptyHealthOverviewStats(), history_over_interval: { buckets: [ { timestamp: '2023-05-15T16:12:14.967Z', - stats: healthStatsMock.getEmptyRuleExecutionStats(), + stats: healthStatsMock.getEmptyHealthOverviewStats(), }, ], }, diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/space_health.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/space_health.ts index 35648a9257570..173f8e9af1a62 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/space_health.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_monitoring/detection_engine_health/model/space_health.ts @@ -6,7 +6,7 @@ */ import type { HealthParameters, HealthSnapshot } from './health_metadata'; -import type { RuleExecutionStats, RuleStats, StatsHistory } from './health_stats'; +import type { HealthOverviewStats, HealthOverviewState, HealthHistory } from './health_stats'; /** * Health calculation parameters for the current Kibana space. @@ -18,27 +18,27 @@ export type SpaceHealthParameters = HealthParameters; */ export interface SpaceHealthSnapshot extends HealthSnapshot { /** - * Health stats at the moment of the calculation request. + * Health state at the moment of the calculation request. */ - stats_at_the_moment: SpaceHealthStatsAtTheMoment; + state_at_the_moment: SpaceHealthState; /** * Health stats calculated over the interval specified in the health parameters. */ - stats_over_interval: SpaceHealthStatsOverInterval; + stats_over_interval: SpaceHealthStats; /** * History of change of the same health stats during the interval. */ - history_over_interval: StatsHistory; + history_over_interval: HealthHistory; } /** - * Health stats at the moment of the calculation request. + * Health state at the moment of the calculation request. */ -export type SpaceHealthStatsAtTheMoment = RuleStats; +export type SpaceHealthState = HealthOverviewState; /** * Health stats calculated over a given interval. */ -export type SpaceHealthStatsOverInterval = RuleExecutionStats; +export type SpaceHealthStats = HealthOverviewStats; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_cluster_health/get_cluster_health_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_cluster_health/get_cluster_health_route.ts index 928c12fdcbd31..719f46788a524 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_cluster_health/get_cluster_health_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_cluster_health/get_cluster_health_route.ts @@ -26,7 +26,7 @@ import { validateGetClusterHealthRequest } from './get_cluster_health_request'; /** * Get health overview of the whole cluster. Scope: all detection rules in all Kibana spaces. * Returns: - * - health stats at the moment of the API call + * - health state at the moment of the API call * - health stats over a specified period of time ("health interval") * - health stats history within the same interval in the form of a histogram * (the same stats are calculated over each of the discreet sub-intervals of the whole interval) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_rule_health/get_rule_health_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_rule_health/get_rule_health_route.ts index 310514d17f968..a69f7961b19f8 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_rule_health/get_rule_health_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_rule_health/get_rule_health_route.ts @@ -23,7 +23,7 @@ import { validateGetRuleHealthRequest } from './get_rule_health_request'; /** * Get health overview of a rule. Scope: a given detection rule in the current Kibana space. * Returns: - * - health stats at the moment of the API call (rule and its execution summary) + * - health state at the moment of the API call (rule and its execution summary) * - health stats over a specified period of time ("health interval") * - health stats history within the same interval in the form of a histogram * (the same stats are calculated over each of the discreet sub-intervals of the whole interval) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_space_health/get_space_health_route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_space_health/get_space_health_route.ts index d76a2212f29c0..96ced4e34151d 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_space_health/get_space_health_route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/api/detection_engine_health/get_space_health/get_space_health_route.ts @@ -26,7 +26,7 @@ import { validateGetSpaceHealthRequest } from './get_space_health_request'; /** * Get health overview of the current Kibana space. Scope: all detection rules in the space. * Returns: - * - health stats at the moment of the API call + * - health state at the moment of the API call * - health stats over a specified period of time ("health interval") * - health stats history within the same interval in the form of a histogram * (the same stats are calculated over each of the discreet sub-intervals of the whole interval) diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/detection_engine_health_client.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/detection_engine_health_client.ts index c4c498bc5ad61..71eb37b7286c6 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/detection_engine_health_client.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/detection_engine_health_client.ts @@ -44,7 +44,7 @@ export const createDetectionEngineHealthClient = ( const statsBasedOnEventLog = await eventLogHealthClient.calculateRuleHealth(args); return { - stats_at_the_moment: statsBasedOnRuleObjects.stats_at_the_moment, + state_at_the_moment: statsBasedOnRuleObjects.state_at_the_moment, stats_over_interval: statsBasedOnEventLog.stats_over_interval, history_over_interval: statsBasedOnEventLog.history_over_interval, debug: { @@ -76,7 +76,7 @@ export const createDetectionEngineHealthClient = ( ]); return { - stats_at_the_moment: statsBasedOnRuleObjects.stats_at_the_moment, + state_at_the_moment: statsBasedOnRuleObjects.state_at_the_moment, stats_over_interval: statsBasedOnEventLog.stats_over_interval, history_over_interval: statsBasedOnEventLog.history_over_interval, debug: { @@ -107,7 +107,7 @@ export const createDetectionEngineHealthClient = ( ]); return { - stats_at_the_moment: statsBasedOnRuleObjects.stats_at_the_moment, + state_at_the_moment: statsBasedOnRuleObjects.state_at_the_moment, stats_over_interval: statsBasedOnEventLog.stats_over_interval, history_over_interval: statsBasedOnEventLog.history_over_interval, debug: { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/health_stats_for_rule.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/health_stats_for_rule.ts index 7704bdd3f2441..72d93f0d67777 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/health_stats_for_rule.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/health_stats_for_rule.ts @@ -11,8 +11,8 @@ import type { AggregateEventsBySavedObjectResult } from '@kbn/event-log-plugin/s import type { HealthIntervalGranularity, RuleHealthSnapshot, - RuleHealthStatsOverInterval, - StatsHistory, + RuleHealthStats, + HealthHistory, } from '../../../../../../../../common/api/detection_engine/rule_monitoring'; import type { RawData } from '../../../utils/normalization'; @@ -57,7 +57,7 @@ const getRuleExecutionStatsHistoryAggregation = ( export const normalizeRuleHealthAggregationResult = ( result: AggregateEventsBySavedObjectResult, requestAggs: Record -): Omit => { +): Omit => { const aggregations = result.aggregations ?? {}; return { stats_over_interval: normalizeRuleExecutionStatsAggregationResult( @@ -76,7 +76,7 @@ export const normalizeRuleHealthAggregationResult = ( const normalizeHistoryOverInterval = ( aggregations: Record -): StatsHistory => { +): HealthHistory => { const statsHistory = aggregations.statsHistory || {}; return { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/rule_execution_stats.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/rule_execution_stats.ts index 7c3b595be1565..32cb62cb42cde 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/rule_execution_stats.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/aggregations/rule_execution_stats.ts @@ -13,7 +13,7 @@ import type { NumberOfDetectedGaps, NumberOfExecutions, NumberOfLoggedMessages, - RuleExecutionStats, + HealthOverviewStats, TopMessages, RuleExecutionStatus, } from '../../../../../../../../common/api/detection_engine/rule_monitoring'; @@ -179,7 +179,7 @@ export const getRuleExecutionStatsAggregation = ( export const normalizeRuleExecutionStatsAggregationResult = ( aggregations: Record, aggregationLevel: RuleExecutionStatsAggregationLevel -): RuleExecutionStats => { +): HealthOverviewStats => { const totalExecutions = aggregations.totalExecutions || {}; const executeEvents = aggregations.executeEvents || {}; const statusChangeEvents = aggregations.statusChangeEvents || {}; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/event_log_health_client.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/event_log_health_client.ts index b593a67cd5a1f..e90c06a01f614 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/event_log_health_client.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/event_log/event_log_health_client.ts @@ -56,9 +56,9 @@ export interface IEventLogHealthClient { calculateClusterHealth(args: ClusterHealthParameters): Promise; } -type RuleHealth = Omit; -type SpaceHealth = Omit; -type ClusterHealth = Omit; +type RuleHealth = Omit; +type SpaceHealth = Omit; +type ClusterHealth = Omit; export const createEventLogHealthClient = ( eventLog: IEventLogClient, diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/health_stats_for_cluster.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/health_stats_for_cluster.ts index a9296f5db012c..f8596ddb7711c 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/health_stats_for_cluster.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/health_stats_for_cluster.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { ClusterHealthStatsAtTheMoment } from '../../../../../../../../common/api/detection_engine/rule_monitoring'; +import type { ClusterHealthState } from '../../../../../../../../common/api/detection_engine/rule_monitoring'; import { getRuleStatsAggregation, normalizeRuleStatsAggregation } from './rule_stats'; export const getClusterHealthAggregation = (): Record< @@ -18,6 +18,6 @@ export const getClusterHealthAggregation = (): Record< export const normalizeClusterHealthAggregationResult = ( aggregations: Record | undefined -): ClusterHealthStatsAtTheMoment => { +): ClusterHealthState => { return normalizeRuleStatsAggregation(aggregations ?? {}); }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/health_stats_for_space.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/health_stats_for_space.ts index aba4e6153ad34..1654459e2ea85 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/health_stats_for_space.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/health_stats_for_space.ts @@ -6,7 +6,7 @@ */ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; -import type { SpaceHealthStatsAtTheMoment } from '../../../../../../../../common/api/detection_engine/rule_monitoring'; +import type { SpaceHealthState } from '../../../../../../../../common/api/detection_engine/rule_monitoring'; import { getRuleStatsAggregation, normalizeRuleStatsAggregation } from './rule_stats'; export const getSpaceHealthAggregation = (): Record< @@ -18,6 +18,6 @@ export const getSpaceHealthAggregation = (): Record< export const normalizeSpaceHealthAggregationResult = ( aggregations: Record -): SpaceHealthStatsAtTheMoment => { +): SpaceHealthState => { return normalizeRuleStatsAggregation(aggregations); }; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/rule_stats.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/rule_stats.ts index 35b75fdbd4e7e..1dc2230909bc3 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/rule_stats.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/aggregations/rule_stats.ts @@ -7,7 +7,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey'; import type { - RuleStats, + HealthOverviewState, TotalEnabledDisabled, } from '../../../../../../../../common/api/detection_engine/rule_monitoring'; import type { RawData } from '../../../utils/normalization'; @@ -51,7 +51,9 @@ export const getRuleStatsAggregation = (): Record< }; }; -export const normalizeRuleStatsAggregation = (aggregations: Record): RuleStats => { +export const normalizeRuleStatsAggregation = ( + aggregations: Record +): HealthOverviewState => { const rulesByEnabled = aggregations.rulesByEnabled || {}; const rulesByOrigin = aggregations.rulesByOrigin || {}; const rulesByType = aggregations.rulesByType || {}; diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/rule_objects_health_client.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/rule_objects_health_client.ts index cff37e3e85f72..6955e1b55c115 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/rule_objects_health_client.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_monitoring/logic/detection_engine_health/rule_objects/rule_objects_health_client.ts @@ -49,9 +49,9 @@ export interface IRuleObjectsHealthClient { calculateClusterHealth(args: ClusterHealthParameters): Promise; } -type RuleHealth = Pick; -type SpaceHealth = Pick; -type ClusterHealth = Pick; +type RuleHealth = Pick; +type SpaceHealth = Pick; +type ClusterHealth = Pick; export const createRuleObjectsHealthClient = ( rulesClient: RulesClientApi, @@ -62,7 +62,7 @@ export const createRuleObjectsHealthClient = ( async calculateRuleHealth(args: RuleHealthParameters): Promise { const rule = await fetchRuleById(rulesClient, args.rule_id); return { - stats_at_the_moment: { rule }, + state_at_the_moment: { rule }, debug: {}, }; }, @@ -72,7 +72,7 @@ export const createRuleObjectsHealthClient = ( const aggregations = await rulesClient.aggregate({ aggs }); return { - stats_at_the_moment: normalizeSpaceHealthAggregationResult(aggregations), + state_at_the_moment: normalizeSpaceHealthAggregationResult(aggregations), debug: { rulesClient: { request: { aggs }, @@ -92,7 +92,7 @@ export const createRuleObjectsHealthClient = ( }); return { - stats_at_the_moment: normalizeClusterHealthAggregationResult(response.aggregations), + state_at_the_moment: normalizeClusterHealthAggregationResult(response.aggregations), debug: { savedObjectsClient: { request: { aggs },