-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synthetics] add default email recovery message (#154862)
## Summary Resolves #153891 <img width="1334" alt="Screen Shot 2023-04-18 at 7 50 20 PM" src="https://user-images.githubusercontent.com/11356435/232928889-09de824f-14ef-426d-8732-6da7fc12eb37.png"> Down email Recovered email <img width="1339" alt="Screen Shot 2023-04-18 at 7 50 30 PM" src="https://user-images.githubusercontent.com/11356435/232928874-4e7c0cbb-b7ec-4684-b0d2-88ec993697df.png"> Please note the `recoverd` typo in the screenshot has been addressed in commits [7c4040f](7c4040f) and [56f637b](56f637b) ### Testing This PR is extremely tricky to test. I have deployed this branch to my own cloud account. This ensures that I can control the allowlist setting for emails on cloud. If you want, I can give you the cloud cluster where this branch is hosted and if you give me your email I can add you to my allowlist settings for you to test. The cloud cluster is current on commit [f889500](f889500)
- Loading branch information
1 parent
c68dfd7
commit 0b71c74
Showing
14 changed files
with
333 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ import { populateAlertActions } from './alert_actions'; | |
import { ActionConnector } from './types'; | ||
import { MONITOR_STATUS } from '../constants/uptime_alerts'; | ||
import { MONITOR_STATUS as SYNTHETICS_MONITOR_STATUS } from '../constants/synthetics_alerts'; | ||
import { MonitorStatusTranslations } from '../translations'; | ||
import { MonitorStatusTranslations } from './legacy_uptime/translations'; | ||
import { SyntheticsMonitorStatusTranslations } from './synthetics/translations'; | ||
|
||
describe('Legacy Alert Actions factory', () => { | ||
|
@@ -33,6 +33,7 @@ describe('Legacy Alert Actions factory', () => { | |
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage, | ||
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage, | ||
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage, | ||
defaultRecoverySubjectMessage: MonitorStatusTranslations.defaultRecoverySubjectMessage, | ||
}, | ||
isLegacy: true, | ||
}); | ||
|
@@ -60,6 +61,70 @@ describe('Legacy Alert Actions factory', () => { | |
]); | ||
}); | ||
|
||
it('generate expected action for email', async () => { | ||
const resp = populateAlertActions({ | ||
groupId: MONITOR_STATUS.id, | ||
defaultActions: [ | ||
{ | ||
actionTypeId: '.email', | ||
group: 'xpack.uptime.alerts.actionGroups.monitorStatus', | ||
params: { | ||
dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', | ||
eventAction: 'trigger', | ||
severity: 'error', | ||
summary: MonitorStatusTranslations.defaultActionMessage, | ||
}, | ||
id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', | ||
}, | ||
] as unknown as ActionConnector[], | ||
translations: { | ||
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage, | ||
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage, | ||
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage, | ||
defaultRecoverySubjectMessage: MonitorStatusTranslations.defaultRecoverySubjectMessage, | ||
}, | ||
isLegacy: true, | ||
defaultEmail: { | ||
to: ['[email protected]'], | ||
}, | ||
}); | ||
expect(resp).toEqual([ | ||
{ | ||
group: 'recovered', | ||
id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', | ||
params: { | ||
bcc: [], | ||
cc: [], | ||
kibanaFooterLink: { | ||
path: '', | ||
text: '', | ||
}, | ||
message: | ||
'Alert for monitor {{context.monitorName}} with url {{{context.monitorUrl}}} from {{context.observerLocation}} has recovered', | ||
subject: | ||
'Monitor {{context.monitorName}} with url {{{context.monitorUrl}}} has recovered', | ||
to: ['[email protected]'], | ||
}, | ||
}, | ||
{ | ||
group: 'xpack.uptime.alerts.actionGroups.monitorStatus', | ||
id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', | ||
params: { | ||
bcc: [], | ||
cc: [], | ||
kibanaFooterLink: { | ||
path: '', | ||
text: '', | ||
}, | ||
message: | ||
'Monitor {{context.monitorName}} with url {{{context.monitorUrl}}} from {{context.observerLocation}} {{{context.statusMessage}}} The latest error message is {{{context.latestErrorMessage}}}, checked at {{context.checkedAt}}', | ||
subject: 'Monitor {{context.monitorName}} with url {{{context.monitorUrl}}} is down', | ||
to: ['[email protected]'], | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
||
it('generate expected action for index', async () => { | ||
const resp = populateAlertActions({ | ||
groupId: MONITOR_STATUS.id, | ||
|
@@ -80,6 +145,7 @@ describe('Legacy Alert Actions factory', () => { | |
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage, | ||
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage, | ||
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage, | ||
defaultRecoverySubjectMessage: MonitorStatusTranslations.defaultRecoverySubjectMessage, | ||
}, | ||
isLegacy: true, | ||
}); | ||
|
@@ -141,6 +207,7 @@ describe('Legacy Alert Actions factory', () => { | |
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage, | ||
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage, | ||
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage, | ||
defaultRecoverySubjectMessage: MonitorStatusTranslations.defaultRecoverySubjectMessage, | ||
}, | ||
}); | ||
expect(resp).toEqual([ | ||
|
@@ -189,6 +256,8 @@ describe('Alert Actions factory', () => { | |
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage, | ||
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage, | ||
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage, | ||
defaultRecoverySubjectMessage: | ||
SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage, | ||
}, | ||
}); | ||
expect(resp).toEqual([ | ||
|
@@ -235,6 +304,8 @@ describe('Alert Actions factory', () => { | |
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage, | ||
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage, | ||
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage, | ||
defaultRecoverySubjectMessage: | ||
SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage, | ||
}, | ||
}); | ||
expect(resp).toEqual([ | ||
|
@@ -295,6 +366,8 @@ describe('Alert Actions factory', () => { | |
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage, | ||
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage, | ||
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage, | ||
defaultRecoverySubjectMessage: | ||
SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage, | ||
}, | ||
}); | ||
expect(resp).toEqual([ | ||
|
@@ -320,4 +393,69 @@ describe('Alert Actions factory', () => { | |
}, | ||
]); | ||
}); | ||
|
||
it('generate expected action for email action connector', async () => { | ||
const resp = populateAlertActions({ | ||
groupId: SYNTHETICS_MONITOR_STATUS.id, | ||
defaultActions: [ | ||
{ | ||
actionTypeId: '.email', | ||
group: 'xpack.synthetics.alerts.actionGroups.monitorStatus', | ||
params: { | ||
dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', | ||
eventAction: 'trigger', | ||
severity: 'error', | ||
summary: | ||
'Monitor {{context.monitorName}} with url {{{context.monitorUrl}}} from {{context.observerLocation}} {{{context.statusMessage}}} The latest error message is {{{context.latestErrorMessage}}}', | ||
}, | ||
id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', | ||
}, | ||
] as unknown as ActionConnector[], | ||
defaultEmail: { | ||
to: ['[email protected]'], | ||
}, | ||
translations: { | ||
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage, | ||
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage, | ||
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage, | ||
defaultRecoverySubjectMessage: | ||
SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage, | ||
}, | ||
}); | ||
expect(resp).toEqual([ | ||
{ | ||
group: 'recovered', | ||
id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', | ||
params: { | ||
bcc: [], | ||
cc: [], | ||
kibanaFooterLink: { | ||
path: '', | ||
text: '', | ||
}, | ||
message: | ||
'The alert for the monitor {{context.monitorName}} checking {{{context.monitorUrl}}} from {{context.locationName}} is no longer active: {{context.recoveryReason}}.', | ||
subject: | ||
'The monitor {{context.monitorName}} checking {{{context.monitorUrl}}} has recovered.', | ||
to: ['[email protected]'], | ||
}, | ||
}, | ||
{ | ||
group: 'xpack.synthetics.alerts.actionGroups.monitorStatus', | ||
id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', | ||
params: { | ||
bcc: [], | ||
cc: [], | ||
kibanaFooterLink: { | ||
path: '', | ||
text: '', | ||
}, | ||
message: | ||
'The monitor {{context.monitorName}} checking {{{context.monitorUrl}}} from {{context.locationName}} last ran at {{context.checkedAt}} and is {{{context.status}}}. The last error received is: {{{context.lastErrorMessage}}}.', | ||
subject: 'The monitor {{context.monitorName}} checking {{{context.monitorUrl}}} is down.', | ||
to: ['[email protected]'], | ||
}, | ||
}, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.