Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5ee89c0
Update alert mapping and add mute, mute all, unmute, and unmute all
fkanout Oct 28, 2025
7050566
[CI] Auto-commit changed files from 'node scripts/eslint_all_files --…
kibanamachine Oct 30, 2025
1fcee65
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Oct 30, 2025
967dd2a
Update tests
fkanout Oct 30, 2025
7902d4c
Update tests
fkanout Oct 30, 2025
da5b85f
Update tests mocks
fkanout Oct 31, 2025
2093d09
Use alert services instead ES client
fkanout Oct 31, 2025
43cc7f5
Update alerts service to store muted alert doc
fkanout Oct 31, 2025
2f891e9
More fixes
fkanout Oct 31, 2025
041624f
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Oct 31, 2025
b2c757a
Update snapshots
fkanout Nov 6, 2025
8e0a0cd
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Nov 6, 2025
1cc2334
Throw error when alert doc muting fails
fkanout Nov 6, 2025
ddb34bc
[Code review] Add muted field for new created alert
fkanout Nov 6, 2025
1305e20
enhance tests and error handling
dominiqueclarke Nov 19, 2025
4629a60
Add _updateMuteState
maryam-saeidi Nov 20, 2025
008a8d2
Fix type
maryam-saeidi Nov 20, 2025
a16daa4
Merge branch 'main' into 240514-store-alert-muted-alert-doc
maryam-saeidi Nov 20, 2025
43a9695
Remove console.log and change order of muteAlertInstance
maryam-saeidi Nov 20, 2025
ee30774
Fix test
maryam-saeidi Nov 20, 2025
7268e0a
Merge branch 'main' into 240514-store-alert-muted-alert-doc
maryam-saeidi Nov 20, 2025
d6ea351
Fix tests
maryam-saeidi Nov 21, 2025
e4f3e9a
Merge branch 'main' into 240514-store-alert-muted-alert-doc
maryam-saeidi Nov 21, 2025
3f8ef47
Code review,
fkanout Nov 25, 2025
c600367
update the test for muted alerts
fkanout Nov 25, 2025
6393ae8
Fix linter and types
fkanout Nov 26, 2025
5620089
Update test to match the new impl
fkanout Nov 26, 2025
5791161
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Nov 26, 2025
1ab72f0
restore checks for indices
fkanout Nov 26, 2025
1e2499d
fix test
fkanout Nov 26, 2025
eabf947
Test updated
fkanout Nov 26, 2025
2cf0570
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Nov 28, 2025
bdf5558
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Nov 28, 2025
9a1cc4e
Fix merge conflicts
fkanout Nov 28, 2025
69bf65c
Update tests
fkanout Nov 28, 2025
8f04a81
Update tests
fkanout Nov 28, 2025
bc96f24
Update x-pack/platform/plugins/shared/alerting/server/alerts_service/…
fkanout Dec 1, 2025
aad9c81
Changes from node scripts/eslint_all_files --no-cache --fix
kibanamachine Dec 1, 2025
c0070a5
Add comment
fkanout Dec 1, 2025
4436b9d
code review
fkanout Dec 1, 2025
bca9853
code review
fkanout Dec 1, 2025
f3b8b13
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Dec 1, 2025
e2002c5
Update test
fkanout Dec 1, 2025
3686d92
Update for flaky test
fkanout Dec 2, 2025
5184de1
another try for the flaky test
fkanout Dec 2, 2025
003da3a
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Dec 2, 2025
9c2ce2a
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Dec 3, 2025
59f4b5a
fix strict 204 test
fkanout Dec 3, 2025
6d0af4a
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Dec 3, 2025
ad530ee
Fix another flaky one
fkanout Dec 3, 2025
9ca97f8
Merge branch 'main' into 240514-store-alert-muted-alert-doc
fkanout Dec 3, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
ALERT_SCHEDULED_ACTION_GROUP,
ALERT_SCHEDULED_ACTION_DATE,
ALERT_SCHEDULED_ACTION_THROTTLING,
ALERT_MUTED,
ALERT_STATE_NAMESPACE,
} from '@kbn/rule-data-utils';
import type { MultiField } from './types';
Expand Down Expand Up @@ -320,6 +321,11 @@ export const alertFieldMap = {
array: false,
required: false,
},
[ALERT_MUTED]: {
Comment thread
maryam-saeidi marked this conversation as resolved.
type: 'boolean',
array: false,
required: false,
},
[ALERT_STATE_NAMESPACE]: {
type: 'unmapped',
array: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const AlertOptional = rt.partial({
'kibana.alert.intended_timestamp': schemaDate,
'kibana.alert.last_detected': schemaDate,
'kibana.alert.maintenance_window_ids': schemaStringArray,
'kibana.alert.muted': schemaBoolean,
'kibana.alert.pending_recovered_count': schemaStringOrNumber,
'kibana.alert.previous_action_group': schemaString,
'kibana.alert.reason': schemaString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const SecurityAttackDiscoveryAlertOptional = rt.partial({
'kibana.alert.intended_timestamp': schemaDate,
'kibana.alert.last_detected': schemaDate,
'kibana.alert.maintenance_window_ids': schemaStringArray,
'kibana.alert.muted': schemaBoolean,
'kibana.alert.pending_recovered_count': schemaStringOrNumber,
'kibana.alert.previous_action_group': schemaString,
'kibana.alert.reason': schemaString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const SecurityAlertOptional = rt.partial({
'kibana.alert.intended_timestamp': schemaDate,
'kibana.alert.last_detected': schemaDate,
'kibana.alert.maintenance_window_ids': schemaStringArray,
'kibana.alert.muted': schemaBoolean,
'kibana.alert.new_terms': schemaStringArray,
'kibana.alert.original_data_stream.dataset': schemaString,
'kibana.alert.original_data_stream.namespace': schemaString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const StreamsAlertOptional = rt.partial({
'kibana.alert.intended_timestamp': schemaDate,
'kibana.alert.last_detected': schemaDate,
'kibana.alert.maintenance_window_ids': schemaStringArray,
'kibana.alert.muted': schemaBoolean,
'kibana.alert.pending_recovered_count': schemaStringOrNumber,
'kibana.alert.previous_action_group': schemaString,
'kibana.alert.reason': schemaString,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ const ALERT_SCHEDULED_ACTION_THROTTLING = `${ALERT_SCHEDULED_ACTION_NAMESPACE}.t
// kibana.alert.index_pattern - index pattern for the alert
const ALERT_INDEX_PATTERN = `${ALERT_NAMESPACE}.index_pattern` as const;

const ALERT_MUTED = `${ALERT_NAMESPACE}.muted` as const;

const namespaces = {
KIBANA_NAMESPACE,
ALERT_NAMESPACE,
Expand Down Expand Up @@ -199,6 +201,7 @@ export const fields = {
SPACE_IDS,
TIMESTAMP,
VERSION,
ALERT_MUTED,
};

export {
Expand Down Expand Up @@ -254,6 +257,7 @@ export {
SPACE_IDS,
TIMESTAMP,
VERSION,
ALERT_MUTED,
};

export type DefaultAlertFieldName = ValuesType<typeof fields & typeof namespaces>;
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@ describe('mappingFromFieldMap', () => {
last_detected: {
type: 'date',
},
muted: {
type: 'boolean',
},
pending_recovered_count: {
type: 'long',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ALERT_FLAPPING_HISTORY,
ALERT_INSTANCE_ID,
ALERT_MAINTENANCE_WINDOW_IDS,
ALERT_MUTED,
ALERT_PENDING_RECOVERED_COUNT,
ALERT_PREVIOUS_ACTION_GROUP,
ALERT_RULE_CATEGORY,
Expand Down Expand Up @@ -164,6 +165,7 @@ const fetchedAlert1 = {
[ALERT_CONSECUTIVE_MATCHES]: 0,
[ALERT_DURATION]: 0,
[ALERT_FLAPPING]: false,
[ALERT_MUTED]: false,
[ALERT_FLAPPING_HISTORY]: [true],
[ALERT_INSTANCE_ID]: '1',
[ALERT_MAINTENANCE_WINDOW_IDS]: [],
Expand Down Expand Up @@ -196,6 +198,7 @@ const fetchedAlert2 = {
[ALERT_CONSECUTIVE_MATCHES]: 0,
[ALERT_DURATION]: 36000000000,
[ALERT_FLAPPING]: false,
[ALERT_MUTED]: false,
[ALERT_FLAPPING_HISTORY]: [true, false],
[ALERT_INSTANCE_ID]: '2',
[ALERT_MAINTENANCE_WINDOW_IDS]: [],
Expand Down Expand Up @@ -236,6 +239,7 @@ const getNewIndexedAlertDoc = (overrides = {}) => ({
[ALERT_CONSECUTIVE_MATCHES]: 1,
[ALERT_DURATION]: 0,
[ALERT_FLAPPING]: false,
[ALERT_MUTED]: false,
[ALERT_FLAPPING_HISTORY]: [true],
[ALERT_INSTANCE_ID]: '1',
[ALERT_MAINTENANCE_WINDOW_IDS]: ['test-id1', 'test-id2'],
Expand Down Expand Up @@ -853,6 +857,7 @@ describe('Alerts Client', () => {
[ALERT_FLAPPING]: false,
[ALERT_FLAPPING_HISTORY]: [true, false],
[ALERT_MAINTENANCE_WINDOW_IDS]: [],
[ALERT_MUTED]: false,
[ALERT_PENDING_RECOVERED_COUNT]: 0,
[ALERT_PREVIOUS_ACTION_GROUP]: 'default',
[ALERT_RULE_CATEGORY]: 'My test rule',
Expand Down Expand Up @@ -1181,6 +1186,7 @@ describe('Alerts Client', () => {
[ALERT_FLAPPING]: false,
[ALERT_FLAPPING_HISTORY]: [true, false, false, false],
[ALERT_MAINTENANCE_WINDOW_IDS]: [],
[ALERT_MUTED]: false,
[ALERT_PENDING_RECOVERED_COUNT]: 0,
[ALERT_PREVIOUS_ACTION_GROUP]: 'default',
[ALERT_RULE_CATEGORY]: 'My test rule',
Expand Down Expand Up @@ -1235,6 +1241,7 @@ describe('Alerts Client', () => {
[ALERT_FLAPPING]: false,
[ALERT_FLAPPING_HISTORY]: [true, true],
[ALERT_MAINTENANCE_WINDOW_IDS]: [],
[ALERT_MUTED]: false,
[ALERT_PENDING_RECOVERED_COUNT]: 0,
[ALERT_PREVIOUS_ACTION_GROUP]: 'default',
[ALERT_SEVERITY_IMPROVING]: true,
Expand Down Expand Up @@ -3030,6 +3037,7 @@ describe('Alerts Client', () => {
[ALERT_ACTION_GROUP]: 'default',
[ALERT_DURATION]: 0,
[ALERT_FLAPPING]: false,
[ALERT_MUTED]: false,
[ALERT_FLAPPING_HISTORY]: [true],
[ALERT_INSTANCE_ID]: '1',
[ALERT_MAINTENANCE_WINDOW_IDS]: ['test-id1', 'test-id2'],
Expand Down Expand Up @@ -3065,6 +3073,7 @@ describe('Alerts Client', () => {
[ALERT_ACTION_GROUP]: 'default',
[ALERT_DURATION]: 0,
[ALERT_FLAPPING]: false,
[ALERT_MUTED]: false,
[ALERT_FLAPPING_HISTORY]: [true],
[ALERT_INSTANCE_ID]: '2',
[ALERT_MAINTENANCE_WINDOW_IDS]: ['test-id1', 'test-id2'],
Expand Down Expand Up @@ -3314,6 +3323,7 @@ describe('Alerts Client', () => {
[ALERT_ACTION_GROUP]: 'default',
[ALERT_DURATION]: 0,
[ALERT_FLAPPING]: false,
[ALERT_MUTED]: false,
[ALERT_FLAPPING_HISTORY]: [true],
[ALERT_INSTANCE_ID]: '1',
[ALERT_MAINTENANCE_WINDOW_IDS]: ['test-id1', 'test-id2'],
Expand Down Expand Up @@ -3418,6 +3428,7 @@ describe('Alerts Client', () => {
[ALERT_ACTION_GROUP]: 'default',
[ALERT_DURATION]: 36000000000,
[ALERT_FLAPPING]: false,
[ALERT_MUTED]: false,
[ALERT_FLAPPING_HISTORY]: [true, false],
[ALERT_INSTANCE_ID]: '1',
[ALERT_MAINTENANCE_WINDOW_IDS]: [],
Expand Down Expand Up @@ -3523,6 +3534,7 @@ describe('Alerts Client', () => {
[ALERT_DURATION]: 36000000000,
[ALERT_END]: date,
[ALERT_FLAPPING]: false,
[ALERT_MUTED]: false,
[ALERT_FLAPPING_HISTORY]: [true, true],
[ALERT_INSTANCE_ID]: '1',
[ALERT_MAINTENANCE_WINDOW_IDS]: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ export class AlertsClient<
alert: trackedAlert,
legacyAlert: activeAlerts[id],
rule: this.rule,
ruleData: this.options.rule,
isImproving,
runTimestamp: this.runTimestampString,
timestamp: currentTime,
Expand All @@ -534,6 +535,7 @@ export class AlertsClient<
>({
legacyAlert: activeAlerts[id],
rule: this.rule,
ruleData: this.options.rule,
runTimestamp: this.runTimestampString,
timestamp: currentTime,
payload: this.reportedAlerts[id],
Expand Down Expand Up @@ -568,6 +570,7 @@ export class AlertsClient<
alert: trackedAlert,
legacyAlert: recoveredAlerts[id],
rule: this.rule,
ruleData: this.options.rule,
runTimestamp: this.runTimestampString,
timestamp: currentTime,
payload: this.reportedAlerts[id],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export const alertRuleData: AlertRuleData = {
spaceId: 'default',
tags: ['rule-', '-tags'],
alertDelay: 0,
muteAll: false,
mutedInstanceIds: [],
};

export const mockAAD = {
Expand Down
Loading