mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Synthetics] add default email recovery message (#154862)
## Summary Resolves https://github.com/elastic/kibana/issues/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](7c4040fda3
) and [56f637b
](56f637b82e
) ### 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
](f889500dc2
)
This commit is contained in:
parent
c68dfd7f9a
commit
0b71c7458d
14 changed files with 333 additions and 156 deletions
|
@ -9,7 +9,7 @@ import { populateAlertActions } from './alert_actions';
|
||||||
import { ActionConnector } from './types';
|
import { ActionConnector } from './types';
|
||||||
import { MONITOR_STATUS } from '../constants/uptime_alerts';
|
import { MONITOR_STATUS } from '../constants/uptime_alerts';
|
||||||
import { MONITOR_STATUS as SYNTHETICS_MONITOR_STATUS } from '../constants/synthetics_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';
|
import { SyntheticsMonitorStatusTranslations } from './synthetics/translations';
|
||||||
|
|
||||||
describe('Legacy Alert Actions factory', () => {
|
describe('Legacy Alert Actions factory', () => {
|
||||||
|
@ -33,6 +33,7 @@ describe('Legacy Alert Actions factory', () => {
|
||||||
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage,
|
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage,
|
||||||
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage,
|
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage,
|
||||||
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage,
|
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage: MonitorStatusTranslations.defaultRecoverySubjectMessage,
|
||||||
},
|
},
|
||||||
isLegacy: true,
|
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: ['test@email.com'],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
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: ['test@email.com'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: ['test@email.com'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
it('generate expected action for index', async () => {
|
it('generate expected action for index', async () => {
|
||||||
const resp = populateAlertActions({
|
const resp = populateAlertActions({
|
||||||
groupId: MONITOR_STATUS.id,
|
groupId: MONITOR_STATUS.id,
|
||||||
|
@ -80,6 +145,7 @@ describe('Legacy Alert Actions factory', () => {
|
||||||
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage,
|
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage,
|
||||||
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage,
|
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage,
|
||||||
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage,
|
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage: MonitorStatusTranslations.defaultRecoverySubjectMessage,
|
||||||
},
|
},
|
||||||
isLegacy: true,
|
isLegacy: true,
|
||||||
});
|
});
|
||||||
|
@ -141,6 +207,7 @@ describe('Legacy Alert Actions factory', () => {
|
||||||
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage,
|
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage,
|
||||||
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage,
|
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage,
|
||||||
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage,
|
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage: MonitorStatusTranslations.defaultRecoverySubjectMessage,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(resp).toEqual([
|
expect(resp).toEqual([
|
||||||
|
@ -189,6 +256,8 @@ describe('Alert Actions factory', () => {
|
||||||
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage,
|
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage,
|
||||||
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
|
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
|
||||||
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
|
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage:
|
||||||
|
SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(resp).toEqual([
|
expect(resp).toEqual([
|
||||||
|
@ -235,6 +304,8 @@ describe('Alert Actions factory', () => {
|
||||||
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage,
|
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage,
|
||||||
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
|
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
|
||||||
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
|
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage:
|
||||||
|
SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(resp).toEqual([
|
expect(resp).toEqual([
|
||||||
|
@ -295,6 +366,8 @@ describe('Alert Actions factory', () => {
|
||||||
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage,
|
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage,
|
||||||
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
|
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
|
||||||
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
|
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage:
|
||||||
|
SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
expect(resp).toEqual([
|
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: ['test@email.com'],
|
||||||
|
},
|
||||||
|
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: ['test@email.com'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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: ['test@email.com'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -36,6 +36,7 @@ interface Translations {
|
||||||
defaultActionMessage: string;
|
defaultActionMessage: string;
|
||||||
defaultRecoveryMessage: string;
|
defaultRecoveryMessage: string;
|
||||||
defaultSubjectMessage: string;
|
defaultSubjectMessage: string;
|
||||||
|
defaultRecoverySubjectMessage: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function populateAlertActions({
|
export function populateAlertActions({
|
||||||
|
@ -107,6 +108,8 @@ export function populateAlertActions({
|
||||||
case EMAIL_ACTION_ID:
|
case EMAIL_ACTION_ID:
|
||||||
if (defaultEmail) {
|
if (defaultEmail) {
|
||||||
action.params = getEmailActionParams(translations, defaultEmail);
|
action.params = getEmailActionParams(translations, defaultEmail);
|
||||||
|
recoveredAction.params = getEmailActionParams(translations, defaultEmail, true);
|
||||||
|
actions.push(recoveredAction);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -270,13 +273,19 @@ function getJiraActionParams({ defaultActionMessage }: Translations): JiraAction
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEmailActionParams(
|
function getEmailActionParams(
|
||||||
{ defaultActionMessage, defaultSubjectMessage }: Translations,
|
{
|
||||||
defaultEmail: DefaultEmail
|
defaultActionMessage,
|
||||||
|
defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage,
|
||||||
|
defaultRecoveryMessage,
|
||||||
|
}: Translations,
|
||||||
|
defaultEmail: DefaultEmail,
|
||||||
|
isRecovery?: boolean
|
||||||
): EmailActionParams {
|
): EmailActionParams {
|
||||||
return {
|
return {
|
||||||
to: defaultEmail.to,
|
to: defaultEmail.to,
|
||||||
subject: defaultSubjectMessage,
|
subject: isRecovery ? defaultRecoverySubjectMessage : defaultSubjectMessage,
|
||||||
message: defaultActionMessage,
|
message: isRecovery ? defaultRecoveryMessage : defaultActionMessage,
|
||||||
cc: defaultEmail.cc ?? [],
|
cc: defaultEmail.cc ?? [],
|
||||||
bcc: defaultEmail.bcc ?? [],
|
bcc: defaultEmail.bcc ?? [],
|
||||||
kibanaFooterLink: {
|
kibanaFooterLink: {
|
||||||
|
|
|
@ -0,0 +1,160 @@
|
||||||
|
/*
|
||||||
|
* 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 { i18n } from '@kbn/i18n';
|
||||||
|
|
||||||
|
export const MonitorStatusTranslations = {
|
||||||
|
defaultActionMessage: i18n.translate(
|
||||||
|
'xpack.synthetics.alerts.monitorStatus.defaultActionMessage',
|
||||||
|
{
|
||||||
|
defaultMessage:
|
||||||
|
'Monitor {monitorName} with url {monitorUrl} from {observerLocation} {statusMessage} The latest error message is {latestErrorMessage}, checked at {checkedAt}',
|
||||||
|
values: {
|
||||||
|
monitorName: '{{context.monitorName}}',
|
||||||
|
monitorUrl: '{{{context.monitorUrl}}}',
|
||||||
|
statusMessage: '{{{context.statusMessage}}}',
|
||||||
|
latestErrorMessage: '{{{context.latestErrorMessage}}}',
|
||||||
|
observerLocation: '{{context.observerLocation}}',
|
||||||
|
checkedAt: '{{context.checkedAt}}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
defaultSubjectMessage: i18n.translate(
|
||||||
|
'xpack.synthetics.alerts.monitorStatus.defaultSubjectMessage',
|
||||||
|
{
|
||||||
|
defaultMessage: 'Monitor {monitorName} with url {monitorUrl} is down',
|
||||||
|
values: {
|
||||||
|
monitorName: '{{context.monitorName}}',
|
||||||
|
monitorUrl: '{{{context.monitorUrl}}}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
defaultRecoverySubjectMessage: i18n.translate(
|
||||||
|
'xpack.synthetics.alerts.monitorStatus.defaultRecoverySubjectMessage',
|
||||||
|
{
|
||||||
|
defaultMessage: 'Monitor {monitorName} with url {monitorUrl} has recovered',
|
||||||
|
values: {
|
||||||
|
monitorName: '{{context.monitorName}}',
|
||||||
|
monitorUrl: '{{{context.monitorUrl}}}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
defaultRecoveryMessage: i18n.translate(
|
||||||
|
'xpack.synthetics.alerts.monitorStatus.defaultRecoveryMessage',
|
||||||
|
{
|
||||||
|
defaultMessage:
|
||||||
|
'Alert for monitor {monitorName} with url {monitorUrl} from {observerLocation} has recovered',
|
||||||
|
values: {
|
||||||
|
monitorName: '{{context.monitorName}}',
|
||||||
|
monitorUrl: '{{{context.monitorUrl}}}',
|
||||||
|
observerLocation: '{{context.observerLocation}}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
name: i18n.translate('xpack.synthetics.alerts.monitorStatus.clientName', {
|
||||||
|
defaultMessage: 'Uptime monitor status',
|
||||||
|
}),
|
||||||
|
description: i18n.translate('xpack.synthetics.alerts.monitorStatus.description', {
|
||||||
|
defaultMessage: 'Alert when a monitor is down or an availability threshold is breached.',
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TlsTranslations = {
|
||||||
|
defaultActionMessage: i18n.translate('xpack.synthetics.alerts.tls.defaultActionMessage', {
|
||||||
|
defaultMessage: `Detected TLS certificate {commonName} from issuer {issuer} is {status}. Certificate {summary}`,
|
||||||
|
values: {
|
||||||
|
commonName: '{{context.commonName}}',
|
||||||
|
issuer: '{{context.issuer}}',
|
||||||
|
summary: '{{context.summary}}',
|
||||||
|
status: '{{context.status}}',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
defaultRecoveryMessage: i18n.translate('xpack.synthetics.alerts.tls.defaultRecoveryMessage', {
|
||||||
|
defaultMessage: `Alert for TLS certificate {commonName} from issuer {issuer} has recovered`,
|
||||||
|
values: {
|
||||||
|
commonName: '{{context.commonName}}',
|
||||||
|
issuer: '{{context.issuer}}',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
name: i18n.translate('xpack.synthetics.alerts.tls.clientName', {
|
||||||
|
defaultMessage: 'Uptime TLS',
|
||||||
|
}),
|
||||||
|
description: i18n.translate('xpack.synthetics.alerts.tls.description', {
|
||||||
|
defaultMessage: 'Alert when the TLS certificate of an Uptime monitor is about to expire.',
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const TlsTranslationsLegacy = {
|
||||||
|
defaultActionMessage: i18n.translate('xpack.synthetics.alerts.tls.legacy.defaultActionMessage', {
|
||||||
|
defaultMessage: `Detected {count} TLS certificates expiring or becoming too old.
|
||||||
|
{expiringConditionalOpen}
|
||||||
|
Expiring cert count: {expiringCount}
|
||||||
|
Expiring Certificates: {expiringCommonNameAndDate}
|
||||||
|
{expiringConditionalClose}
|
||||||
|
{agingConditionalOpen}
|
||||||
|
Aging cert count: {agingCount}
|
||||||
|
Aging Certificates: {agingCommonNameAndDate}
|
||||||
|
{agingConditionalClose}
|
||||||
|
`,
|
||||||
|
values: {
|
||||||
|
count: '{{state.count}}',
|
||||||
|
expiringCount: '{{state.expiringCount}}',
|
||||||
|
expiringCommonNameAndDate: '{{state.expiringCommonNameAndDate}}',
|
||||||
|
expiringConditionalOpen: '{{#state.hasExpired}}',
|
||||||
|
expiringConditionalClose: '{{/state.hasExpired}}',
|
||||||
|
agingCount: '{{state.agingCount}}',
|
||||||
|
agingCommonNameAndDate: '{{state.agingCommonNameAndDate}}',
|
||||||
|
agingConditionalOpen: '{{#state.hasAging}}',
|
||||||
|
agingConditionalClose: '{{/state.hasAging}}',
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
name: i18n.translate('xpack.synthetics.alerts.tls.legacy.clientName', {
|
||||||
|
defaultMessage: 'Uptime TLS (Legacy)',
|
||||||
|
}),
|
||||||
|
description: i18n.translate('xpack.synthetics.alerts.tls.legacy.description', {
|
||||||
|
defaultMessage:
|
||||||
|
'Alert when the TLS certificate of an Uptime monitor is about to expire. This alert will be deprecated in a future version.',
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
export const DurationAnomalyTranslations = {
|
||||||
|
defaultActionMessage: i18n.translate(
|
||||||
|
'xpack.synthetics.alerts.durationAnomaly.defaultActionMessage',
|
||||||
|
{
|
||||||
|
defaultMessage: `Abnormal ({severity} level) response time detected on {monitor} with url {monitorUrl} at {anomalyStartTimestamp}. Anomaly severity score is {severityScore}.
|
||||||
|
Response times as high as {slowestAnomalyResponse} have been detected from location {observerLocation}. Expected response time is {expectedResponseTime}.`,
|
||||||
|
values: {
|
||||||
|
severity: '{{context.severity}}',
|
||||||
|
anomalyStartTimestamp: '{{context.anomalyStartTimestamp}}',
|
||||||
|
monitor: '{{context.monitor}}',
|
||||||
|
monitorUrl: '{{{context.monitorUrl}}}',
|
||||||
|
slowestAnomalyResponse: '{{context.slowestAnomalyResponse}}',
|
||||||
|
expectedResponseTime: '{{context.expectedResponseTime}}',
|
||||||
|
severityScore: '{{context.severityScore}}',
|
||||||
|
observerLocation: '{{context.observerLocation}}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
defaultRecoveryMessage: i18n.translate(
|
||||||
|
'xpack.synthetics.alerts.durationAnomaly.defaultRecoveryMessage',
|
||||||
|
{
|
||||||
|
defaultMessage: `Alert for abnormal ({severity} level) response time detected on monitor {monitor} with url {monitorUrl} from location {observerLocation} at {anomalyStartTimestamp} has recovered`,
|
||||||
|
values: {
|
||||||
|
severity: '{{context.severity}}',
|
||||||
|
anomalyStartTimestamp: '{{context.anomalyStartTimestamp}}',
|
||||||
|
monitor: '{{context.monitor}}',
|
||||||
|
monitorUrl: '{{{context.monitorUrl}}}',
|
||||||
|
observerLocation: '{{context.observerLocation}}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
|
name: i18n.translate('xpack.synthetics.alerts.durationAnomaly.clientName', {
|
||||||
|
defaultMessage: 'Uptime Duration Anomaly',
|
||||||
|
}),
|
||||||
|
description: i18n.translate('xpack.synthetics.alerts.durationAnomaly.description', {
|
||||||
|
defaultMessage: 'Alert when the Uptime monitor duration is anomalous.',
|
||||||
|
}),
|
||||||
|
};
|
|
@ -33,6 +33,16 @@ export const SyntheticsMonitorStatusTranslations = {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
defaultRecoverySubjectMessage: i18n.translate(
|
||||||
|
'xpack.synthetics.alerts.syntheticsMonitorStatus.defaultRecoverySubjectMessage',
|
||||||
|
{
|
||||||
|
defaultMessage: 'The monitor {monitorName} checking {monitorUrl} has recovered.',
|
||||||
|
values: {
|
||||||
|
monitorName: '{{context.monitorName}}',
|
||||||
|
monitorUrl: '{{{context.monitorUrl}}}',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
),
|
||||||
defaultRecoveryMessage: i18n.translate(
|
defaultRecoveryMessage: i18n.translate(
|
||||||
'xpack.synthetics.alerts.syntheticsMonitorStatus.defaultRecoveryMessage',
|
'xpack.synthetics.alerts.syntheticsMonitorStatus.defaultRecoveryMessage',
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,146 +20,3 @@ export const VALUE_MUST_BE_AN_INTEGER = i18n.translate(
|
||||||
defaultMessage: 'Value must be an integer.',
|
defaultMessage: 'Value must be an integer.',
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const MonitorStatusTranslations = {
|
|
||||||
defaultActionMessage: i18n.translate(
|
|
||||||
'xpack.synthetics.alerts.monitorStatus.defaultActionMessage',
|
|
||||||
{
|
|
||||||
defaultMessage:
|
|
||||||
'Monitor {monitorName} with url {monitorUrl} from {observerLocation} {statusMessage} The latest error message is {latestErrorMessage}, checked at {checkedAt}',
|
|
||||||
values: {
|
|
||||||
monitorName: '{{context.monitorName}}',
|
|
||||||
monitorUrl: '{{{context.monitorUrl}}}',
|
|
||||||
statusMessage: '{{{context.statusMessage}}}',
|
|
||||||
latestErrorMessage: '{{{context.latestErrorMessage}}}',
|
|
||||||
observerLocation: '{{context.observerLocation}}',
|
|
||||||
checkedAt: '{{context.checkedAt}}',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
defaultSubjectMessage: i18n.translate(
|
|
||||||
'xpack.synthetics.alerts.monitorStatus.defaultSubjectMessage',
|
|
||||||
{
|
|
||||||
defaultMessage: 'Monitor {monitorName} with url {monitorUrl} is down',
|
|
||||||
values: {
|
|
||||||
monitorName: '{{context.monitorName}}',
|
|
||||||
monitorUrl: '{{{context.monitorUrl}}}',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
defaultRecoveryMessage: i18n.translate(
|
|
||||||
'xpack.synthetics.alerts.monitorStatus.defaultRecoveryMessage',
|
|
||||||
{
|
|
||||||
defaultMessage:
|
|
||||||
'Alert for monitor {monitorName} with url {monitorUrl} from {observerLocation} has recovered',
|
|
||||||
values: {
|
|
||||||
monitorName: '{{context.monitorName}}',
|
|
||||||
monitorUrl: '{{{context.monitorUrl}}}',
|
|
||||||
observerLocation: '{{context.observerLocation}}',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
name: i18n.translate('xpack.synthetics.alerts.monitorStatus.clientName', {
|
|
||||||
defaultMessage: 'Uptime monitor status',
|
|
||||||
}),
|
|
||||||
description: i18n.translate('xpack.synthetics.alerts.monitorStatus.description', {
|
|
||||||
defaultMessage: 'Alert when a monitor is down or an availability threshold is breached.',
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
export const TlsTranslations = {
|
|
||||||
defaultActionMessage: i18n.translate('xpack.synthetics.alerts.tls.defaultActionMessage', {
|
|
||||||
defaultMessage: `Detected TLS certificate {commonName} from issuer {issuer} is {status}. Certificate {summary}`,
|
|
||||||
values: {
|
|
||||||
commonName: '{{context.commonName}}',
|
|
||||||
issuer: '{{context.issuer}}',
|
|
||||||
summary: '{{context.summary}}',
|
|
||||||
status: '{{context.status}}',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
defaultRecoveryMessage: i18n.translate('xpack.synthetics.alerts.tls.defaultRecoveryMessage', {
|
|
||||||
defaultMessage: `Alert for TLS certificate {commonName} from issuer {issuer} has recovered`,
|
|
||||||
values: {
|
|
||||||
commonName: '{{context.commonName}}',
|
|
||||||
issuer: '{{context.issuer}}',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
name: i18n.translate('xpack.synthetics.alerts.tls.clientName', {
|
|
||||||
defaultMessage: 'Uptime TLS',
|
|
||||||
}),
|
|
||||||
description: i18n.translate('xpack.synthetics.alerts.tls.description', {
|
|
||||||
defaultMessage: 'Alert when the TLS certificate of an Uptime monitor is about to expire.',
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
export const TlsTranslationsLegacy = {
|
|
||||||
defaultActionMessage: i18n.translate('xpack.synthetics.alerts.tls.legacy.defaultActionMessage', {
|
|
||||||
defaultMessage: `Detected {count} TLS certificates expiring or becoming too old.
|
|
||||||
{expiringConditionalOpen}
|
|
||||||
Expiring cert count: {expiringCount}
|
|
||||||
Expiring Certificates: {expiringCommonNameAndDate}
|
|
||||||
{expiringConditionalClose}
|
|
||||||
{agingConditionalOpen}
|
|
||||||
Aging cert count: {agingCount}
|
|
||||||
Aging Certificates: {agingCommonNameAndDate}
|
|
||||||
{agingConditionalClose}
|
|
||||||
`,
|
|
||||||
values: {
|
|
||||||
count: '{{state.count}}',
|
|
||||||
expiringCount: '{{state.expiringCount}}',
|
|
||||||
expiringCommonNameAndDate: '{{state.expiringCommonNameAndDate}}',
|
|
||||||
expiringConditionalOpen: '{{#state.hasExpired}}',
|
|
||||||
expiringConditionalClose: '{{/state.hasExpired}}',
|
|
||||||
agingCount: '{{state.agingCount}}',
|
|
||||||
agingCommonNameAndDate: '{{state.agingCommonNameAndDate}}',
|
|
||||||
agingConditionalOpen: '{{#state.hasAging}}',
|
|
||||||
agingConditionalClose: '{{/state.hasAging}}',
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
name: i18n.translate('xpack.synthetics.alerts.tls.legacy.clientName', {
|
|
||||||
defaultMessage: 'Uptime TLS (Legacy)',
|
|
||||||
}),
|
|
||||||
description: i18n.translate('xpack.synthetics.alerts.tls.legacy.description', {
|
|
||||||
defaultMessage:
|
|
||||||
'Alert when the TLS certificate of an Uptime monitor is about to expire. This alert will be deprecated in a future version.',
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
export const DurationAnomalyTranslations = {
|
|
||||||
defaultActionMessage: i18n.translate(
|
|
||||||
'xpack.synthetics.alerts.durationAnomaly.defaultActionMessage',
|
|
||||||
{
|
|
||||||
defaultMessage: `Abnormal ({severity} level) response time detected on {monitor} with url {monitorUrl} at {anomalyStartTimestamp}. Anomaly severity score is {severityScore}.
|
|
||||||
Response times as high as {slowestAnomalyResponse} have been detected from location {observerLocation}. Expected response time is {expectedResponseTime}.`,
|
|
||||||
values: {
|
|
||||||
severity: '{{context.severity}}',
|
|
||||||
anomalyStartTimestamp: '{{context.anomalyStartTimestamp}}',
|
|
||||||
monitor: '{{context.monitor}}',
|
|
||||||
monitorUrl: '{{{context.monitorUrl}}}',
|
|
||||||
slowestAnomalyResponse: '{{context.slowestAnomalyResponse}}',
|
|
||||||
expectedResponseTime: '{{context.expectedResponseTime}}',
|
|
||||||
severityScore: '{{context.severityScore}}',
|
|
||||||
observerLocation: '{{context.observerLocation}}',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
defaultRecoveryMessage: i18n.translate(
|
|
||||||
'xpack.synthetics.alerts.durationAnomaly.defaultRecoveryMessage',
|
|
||||||
{
|
|
||||||
defaultMessage: `Alert for abnormal ({severity} level) response time detected on monitor {monitor} with url {monitorUrl} from location {observerLocation} at {anomalyStartTimestamp} has recovered`,
|
|
||||||
values: {
|
|
||||||
severity: '{{context.severity}}',
|
|
||||||
anomalyStartTimestamp: '{{context.anomalyStartTimestamp}}',
|
|
||||||
monitor: '{{context.monitor}}',
|
|
||||||
monitorUrl: '{{{context.monitorUrl}}}',
|
|
||||||
observerLocation: '{{context.observerLocation}}',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
),
|
|
||||||
name: i18n.translate('xpack.synthetics.alerts.durationAnomaly.clientName', {
|
|
||||||
defaultMessage: 'Uptime Duration Anomaly',
|
|
||||||
}),
|
|
||||||
description: i18n.translate('xpack.synthetics.alerts.durationAnomaly.description', {
|
|
||||||
defaultMessage: 'Alert when the Uptime monitor duration is anomalous.',
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import { ObservabilityRuleTypeModel } from '@kbn/observability-plugin/public';
|
||||||
import { AlertTypeInitializer } from '.';
|
import { AlertTypeInitializer } from '.';
|
||||||
import { getMonitorRouteFromMonitorId } from '../../../../common/utils/get_monitor_url';
|
import { getMonitorRouteFromMonitorId } from '../../../../common/utils/get_monitor_url';
|
||||||
import { CLIENT_ALERT_TYPES } from '../../../../common/constants/uptime_alerts';
|
import { CLIENT_ALERT_TYPES } from '../../../../common/constants/uptime_alerts';
|
||||||
import { DurationAnomalyTranslations } from '../../../../common/translations';
|
import { DurationAnomalyTranslations } from '../../../../common/rules/legacy_uptime/translations';
|
||||||
|
|
||||||
const { defaultActionMessage, defaultRecoveryMessage, description } = DurationAnomalyTranslations;
|
const { defaultActionMessage, defaultRecoveryMessage, description } = DurationAnomalyTranslations;
|
||||||
const DurationAnomalyAlert = React.lazy(() => import('./lazy_wrapper/duration_anomaly'));
|
const DurationAnomalyAlert = React.lazy(() => import('./lazy_wrapper/duration_anomaly'));
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { ObservabilityRuleTypeModel } from '@kbn/observability-plugin/public';
|
||||||
import { ValidationResult } from '@kbn/triggers-actions-ui-plugin/public';
|
import { ValidationResult } from '@kbn/triggers-actions-ui-plugin/public';
|
||||||
import { AlertTypeInitializer } from '.';
|
import { AlertTypeInitializer } from '.';
|
||||||
import { getMonitorRouteFromMonitorId } from '../../../../common/utils/get_monitor_url';
|
import { getMonitorRouteFromMonitorId } from '../../../../common/utils/get_monitor_url';
|
||||||
import { MonitorStatusTranslations } from '../../../../common/translations';
|
import { MonitorStatusTranslations } from '../../../../common/rules/legacy_uptime/translations';
|
||||||
import { CLIENT_ALERT_TYPES } from '../../../../common/constants/uptime_alerts';
|
import { CLIENT_ALERT_TYPES } from '../../../../common/constants/uptime_alerts';
|
||||||
|
|
||||||
const { defaultActionMessage, defaultRecoveryMessage, description } = MonitorStatusTranslations;
|
const { defaultActionMessage, defaultRecoveryMessage, description } = MonitorStatusTranslations;
|
||||||
|
|
|
@ -12,7 +12,7 @@ import type { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plu
|
||||||
import { ValidationResult } from '@kbn/triggers-actions-ui-plugin/public';
|
import { ValidationResult } from '@kbn/triggers-actions-ui-plugin/public';
|
||||||
import { TLSParams } from '../../../../common/runtime_types/alerts/tls';
|
import { TLSParams } from '../../../../common/runtime_types/alerts/tls';
|
||||||
import { CLIENT_ALERT_TYPES } from '../../../../common/constants/uptime_alerts';
|
import { CLIENT_ALERT_TYPES } from '../../../../common/constants/uptime_alerts';
|
||||||
import { TlsTranslations } from '../../../../common/translations';
|
import { TlsTranslations } from '../../../../common/rules/legacy_uptime/translations';
|
||||||
import { AlertTypeInitializer } from '.';
|
import { AlertTypeInitializer } from '.';
|
||||||
|
|
||||||
import { CERTIFICATES_ROUTE } from '../../../../common/constants/ui';
|
import { CERTIFICATES_ROUTE } from '../../../../common/constants/ui';
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { RuleTypeModel } from '@kbn/triggers-actions-ui-plugin/public';
|
import { RuleTypeModel } from '@kbn/triggers-actions-ui-plugin/public';
|
||||||
import { CLIENT_ALERT_TYPES } from '../../../../common/constants/uptime_alerts';
|
import { CLIENT_ALERT_TYPES } from '../../../../common/constants/uptime_alerts';
|
||||||
import { TlsTranslationsLegacy } from '../../../../common/translations';
|
import { TlsTranslationsLegacy } from '../../../../common/rules/legacy_uptime/translations';
|
||||||
import { AlertTypeInitializer } from '.';
|
import { AlertTypeInitializer } from '.';
|
||||||
|
|
||||||
const { defaultActionMessage, description } = TlsTranslationsLegacy;
|
const { defaultActionMessage, description } = TlsTranslationsLegacy;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
import type { ActionType, AsApiContract, Rule } from '@kbn/triggers-actions-ui-plugin/public';
|
import type { ActionType, AsApiContract, Rule } from '@kbn/triggers-actions-ui-plugin/public';
|
||||||
import { RuleTypeParams } from '@kbn/alerting-plugin/common';
|
import { RuleTypeParams } from '@kbn/alerting-plugin/common';
|
||||||
import { MonitorStatusTranslations } from '../../../../common/translations';
|
import { MonitorStatusTranslations } from '../../../../common/rules/legacy_uptime/translations';
|
||||||
import { ActionConnector } from '../../../../common/rules/types';
|
import { ActionConnector } from '../../../../common/rules/types';
|
||||||
import { CLIENT_ALERT_TYPES, MONITOR_STATUS } from '../../../../common/constants/uptime_alerts';
|
import { CLIENT_ALERT_TYPES, MONITOR_STATUS } from '../../../../common/constants/uptime_alerts';
|
||||||
import { apiService } from './utils';
|
import { apiService } from './utils';
|
||||||
|
@ -87,6 +87,7 @@ export const createAlert = async ({
|
||||||
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage,
|
defaultActionMessage: MonitorStatusTranslations.defaultActionMessage,
|
||||||
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage,
|
defaultRecoveryMessage: MonitorStatusTranslations.defaultRecoveryMessage,
|
||||||
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage,
|
defaultSubjectMessage: MonitorStatusTranslations.defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage: MonitorStatusTranslations.defaultRecoverySubjectMessage,
|
||||||
},
|
},
|
||||||
isLegacy: true,
|
isLegacy: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -30,7 +30,7 @@ import { UptimeAlertTypeFactory } from './types';
|
||||||
import { Ping } from '../../../../common/runtime_types/ping';
|
import { Ping } from '../../../../common/runtime_types/ping';
|
||||||
import { getMLJobId } from '../../../../common/lib';
|
import { getMLJobId } from '../../../../common/lib';
|
||||||
|
|
||||||
import { DurationAnomalyTranslations as CommonDurationAnomalyTranslations } from '../../../../common/translations';
|
import { DurationAnomalyTranslations as CommonDurationAnomalyTranslations } from '../../../../common/rules/legacy_uptime/translations';
|
||||||
import { getMonitorRouteFromMonitorId } from '../../../../common/utils/get_monitor_url';
|
import { getMonitorRouteFromMonitorId } from '../../../../common/utils/get_monitor_url';
|
||||||
|
|
||||||
import { ALERT_REASON_MSG, ACTION_VARIABLES, VIEW_IN_APP_URL } from './action_variables';
|
import { ALERT_REASON_MSG, ACTION_VARIABLES, VIEW_IN_APP_URL } from './action_variables';
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { CLIENT_ALERT_TYPES, TLS } from '../../../../common/constants/uptime_ale
|
||||||
import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../common/constants';
|
import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../common/constants';
|
||||||
import { Cert, CertResult } from '../../../../common/runtime_types';
|
import { Cert, CertResult } from '../../../../common/runtime_types';
|
||||||
import { commonStateTranslations, tlsTranslations } from './translations';
|
import { commonStateTranslations, tlsTranslations } from './translations';
|
||||||
import { TlsTranslations } from '../../../../common/translations';
|
import { TlsTranslations } from '../../../../common/rules/legacy_uptime/translations';
|
||||||
|
|
||||||
import { savedObjectsAdapter } from '../saved_objects/saved_objects';
|
import { savedObjectsAdapter } from '../saved_objects/saved_objects';
|
||||||
import { UptimeEsClient } from '../lib';
|
import { UptimeEsClient } from '../lib';
|
||||||
|
|
|
@ -114,6 +114,8 @@ export class StatusAlertService {
|
||||||
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage,
|
defaultActionMessage: SyntheticsMonitorStatusTranslations.defaultActionMessage,
|
||||||
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
|
defaultRecoveryMessage: SyntheticsMonitorStatusTranslations.defaultRecoveryMessage,
|
||||||
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
|
defaultSubjectMessage: SyntheticsMonitorStatusTranslations.defaultSubjectMessage,
|
||||||
|
defaultRecoverySubjectMessage:
|
||||||
|
SyntheticsMonitorStatusTranslations.defaultRecoverySubjectMessage,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import expect from '@kbn/expect';
|
import expect from '@kbn/expect';
|
||||||
import { MonitorStatusTranslations } from '@kbn/synthetics-plugin/common/translations';
|
import { MonitorStatusTranslations } from '@kbn/synthetics-plugin/common/rules/legacy_uptime/translations';
|
||||||
import { FtrProviderContext } from '../../../ftr_provider_context';
|
import { FtrProviderContext } from '../../../ftr_provider_context';
|
||||||
import { deleteUptimeSettingsObject } from '../../../../functional/apps/uptime';
|
import { deleteUptimeSettingsObject } from '../../../../functional/apps/uptime';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue