Skip to content

Commit

Permalink
Switches RuleDetails to query alerts by ruleId instead of SO id
Browse files Browse the repository at this point in the history
  • Loading branch information
spong committed Dec 1, 2021
1 parent 3de6de9 commit ca5975c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ALERT_RULE_CATEGORY,
ALERT_RULE_SEVERITY,
ALERT_RULE_RISK_SCORE,
ALERT_RULE_RULE_ID,
} from '@kbn/rule-data-utils/technical_field_names';

import type { Filter } from '@kbn/es-query';
Expand Down Expand Up @@ -103,14 +104,14 @@ export const buildAlertsRuleIdFilter = (ruleId: string | null): Filter[] =>
negate: false,
disabled: false,
type: 'phrase',
key: 'kibana.alert.rule.uuid',
key: ALERT_RULE_RULE_ID,
params: {
query: ruleId,
},
},
query: {
match_phrase: {
'kibana.alert.rule.uuid': ruleId,
[ALERT_RULE_RULE_ID]: ruleId,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({

const alertDefaultFilters = useMemo(
() => [
...buildAlertsRuleIdFilter(ruleId),
...buildAlertsRuleIdFilter(rule?.rule_id ?? ''),
...(ruleRegistryEnabled
? [
...buildShowBuildingBlockFilterRuleRegistry(showBuildingBlockAlerts), // TODO: Once we are past experimental phase this code should be removed
Expand All @@ -428,18 +428,12 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
]),
...buildThreatMatchFilter(showOnlyThreatIndicatorAlerts),
],
[
ruleId,
ruleRegistryEnabled,
showBuildingBlockAlerts,
showOnlyThreatIndicatorAlerts,
filterGroup,
]
[rule, ruleRegistryEnabled, showBuildingBlockAlerts, showOnlyThreatIndicatorAlerts, filterGroup]
);

const alertsTableDefaultFilters = useMemo(
() => [
...buildAlertsRuleIdFilter(ruleId),
...buildAlertsRuleIdFilter(rule?.rule_id ?? ''),
...(ruleRegistryEnabled
? [
// TODO: Once we are past experimental phase this code should be removed
Expand All @@ -448,7 +442,7 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
: [...buildShowBuildingBlockFilter(showBuildingBlockAlerts)]),
...buildThreatMatchFilter(showOnlyThreatIndicatorAlerts),
],
[ruleId, ruleRegistryEnabled, showBuildingBlockAlerts, showOnlyThreatIndicatorAlerts]
[rule, ruleRegistryEnabled, showBuildingBlockAlerts, showOnlyThreatIndicatorAlerts]
);

const alertMergedFilters = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export const getFailingRules = async (
try {
const errorRules = await Promise.all(
ids.map(async (id) =>
rulesClient.get({
rulesClient.resolve({
id,
})
)
Expand Down

0 comments on commit ca5975c

Please sign in to comment.