Skip to content

Commit

Permalink
uptime - index default severity of warning for tls and monitor status…
Browse files Browse the repository at this point in the history
… alerts (#108731)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dominiqueclarke and kibanamachine authored Aug 17, 2021
1 parent 720a609 commit 15494cd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions packages/kbn-rule-data-utils/src/alerts_as_data_severity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const ALERT_SEVERITY_WARNING = 'warning';
export const ALERT_SEVERITY_CRITICAL = 'critical';
export type AlertSeverity = typeof ALERT_SEVERITY_WARNING | typeof ALERT_SEVERITY_CRITICAL;
1 change: 1 addition & 0 deletions packages/kbn-rule-data-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@

export * from './technical_field_names';
export * from './alerts_as_data_rbac';
export * from './alerts_as_data_severity';
4 changes: 3 additions & 1 deletion x-pack/plugins/uptime/server/lib/alerts/status_check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { ALERT_REASON } from '@kbn/rule-data-utils';
import { ALERT_REASON, ALERT_SEVERITY_WARNING, ALERT_SEVERITY_LEVEL } from '@kbn/rule-data-utils';
import {
generateFilterDSL,
hasFilters,
Expand Down Expand Up @@ -75,6 +75,7 @@ const mockStatusAlertDocument = (
[ALERT_REASON]: `Monitor first with url ${monitorInfo?.url?.full} is down from ${
monitorInfo.observer?.geo?.name
}. The latest error message is ${monitorInfo.error?.message || ''}`,
[ALERT_SEVERITY_LEVEL]: ALERT_SEVERITY_WARNING,
},
id: getInstanceId(
monitorInfo,
Expand All @@ -95,6 +96,7 @@ const mockAvailabilityAlertDocument = (monitor: GetMonitorAvailabilityResult) =>
)}% availability expected is 99.34% from ${
monitorInfo.observer?.geo?.name
}. The latest error message is ${monitorInfo.error?.message || ''}`,
[ALERT_SEVERITY_LEVEL]: ALERT_SEVERITY_WARNING,
},
id: getInstanceId(monitorInfo, `${monitorInfo?.monitor.id}-${monitorInfo.observer?.geo?.name}`),
};
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/uptime/server/lib/alerts/status_check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { min } from 'lodash';
import datemath from '@elastic/datemath';
import { schema } from '@kbn/config-schema';
import { ALERT_SEVERITY_WARNING, ALERT_SEVERITY_LEVEL } from '@kbn/rule-data-utils';
import { i18n } from '@kbn/i18n';
import { JsonObject } from '@kbn/utility-types';
import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query';
Expand Down Expand Up @@ -158,6 +159,7 @@ export const getMonitorAlertDocument = (monitorSummary: Record<string, string |
'observer.geo.name': monitorSummary.observerLocation,
'error.message': monitorSummary.latestErrorMessage,
'agent.name': monitorSummary.observerHostname,
[ALERT_SEVERITY_LEVEL]: ALERT_SEVERITY_WARNING,
[ALERT_REASON]: monitorSummary.reason,
});

Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/uptime/server/lib/alerts/tls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/
import moment from 'moment';
import { ALERT_SEVERITY_WARNING, ALERT_SEVERITY_LEVEL } from '@kbn/rule-data-utils';
import { tlsAlertFactory, getCertSummary, DEFAULT_SIZE } from './tls';
import { TLS } from '../../../common/constants/alerts';
import { CertResult, DynamicSettings } from '../../../common/runtime_types';
Expand Down Expand Up @@ -115,6 +116,7 @@ describe('tls alert', () => {
'tls.server.x509.not_after': cert.not_after,
'tls.server.x509.not_before': cert.not_before,
'tls.server.hash.sha256': cert.sha256,
[ALERT_SEVERITY_LEVEL]: ALERT_SEVERITY_WARNING,
}),
id: `${cert.common_name}-${cert.issuer?.replace(/\s/g, '_')}-${cert.sha256}`,
});
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/uptime/server/lib/alerts/tls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
import moment from 'moment';
import { schema } from '@kbn/config-schema';
import { ALERT_REASON } from '@kbn/rule-data-utils';
import { ALERT_REASON, ALERT_SEVERITY_WARNING, ALERT_SEVERITY_LEVEL } from '@kbn/rule-data-utils';
import { UptimeAlertTypeFactory } from './types';
import { updateState, generateAlertMessage } from './common';
import { TLS } from '../../../common/constants/alerts';
Expand Down Expand Up @@ -172,6 +172,7 @@ export const tlsAlertFactory: UptimeAlertTypeFactory<ActionGroupIds> = (_server,
'tls.server.x509.not_after': cert.not_after,
'tls.server.x509.not_before': cert.not_before,
'tls.server.hash.sha256': cert.sha256,
[ALERT_SEVERITY_LEVEL]: ALERT_SEVERITY_WARNING,
[ALERT_REASON]: generateAlertMessage(TlsTranslations.defaultActionMessage, summary),
},
});
Expand Down

0 comments on commit 15494cd

Please sign in to comment.