Skip to content

Commit

Permalink
Add descriptions to alert types (#81850) (#82481)
Browse files Browse the repository at this point in the history
* Initial attempt at adding descriptions to alert types

* Fix typecheck failures

* Fix i18n check

* Fix failing jest test

* Fix i18n check again

* Apply changes for Uptime

* Update x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts

Co-authored-by: Casper Hübertz <casper@formgeist.com>

* Update x-pack/plugins/apm/public/components/alerting/register_apm_alerts.ts

Co-authored-by: Casper Hübertz <casper@formgeist.com>

* Fix jest test

* Update geo threshold description

* Update description of some alert types based on feedback from Gail

* Update description of some alert types based on feedback from Gail

* Fix i18n

* Fix i18n

* Fix ESLint

* Update some copy

* Update uptime alert description

* Fix typos

Co-authored-by: Casper Hübertz <casper@formgeist.com>

Co-authored-by: Casper Hübertz <casper@formgeist.com>
  • Loading branch information
mikecote and formgeist committed Nov 3, 2020
1 parent fe4c56f commit b0d7421
Show file tree
Hide file tree
Showing 39 changed files with 132 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function getAlertType(): AlertTypeModel {
return {
id: 'example.always-firing',
name: 'Always Fires',
description: 'Alert when called',
iconClass: 'bolt',
alertParamsExpression: AlwaysFiringExpression,
validate: (alertParams: AlwaysFiringParamsProps['alertParams']) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export function getAlertType(): AlertTypeModel {
return {
id: 'example.people-in-space',
name: 'People Are In Space Right Now',
description: 'Alert when people are in space right now',
iconClass: 'globe',
alertParamsExpression: PeopleinSpaceExpression,
validate: (alertParams: PeopleinSpaceParamsProps['alertParams']) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export function registerApmAlerts(
name: i18n.translate('xpack.apm.alertTypes.errorCount', {
defaultMessage: 'Error count threshold',
}),
description: i18n.translate('xpack.apm.alertTypes.errorCount.description', {
defaultMessage:
'Alert when the number of errors in a service exceeds a defined threshold.',
}),
iconClass: 'bell',
alertParamsExpression: lazy(() => import('./ErrorCountAlertTrigger')),
validate: () => ({
Expand All @@ -41,6 +45,13 @@ export function registerApmAlerts(
name: i18n.translate('xpack.apm.alertTypes.transactionDuration', {
defaultMessage: 'Transaction duration threshold',
}),
description: i18n.translate(
'xpack.apm.alertTypes.transactionDuration.description',
{
defaultMessage:
'Alert when the duration of a specific transaction type in a service exceeds a defined threshold.',
}
),
iconClass: 'bell',
alertParamsExpression: lazy(
() => import('./TransactionDurationAlertTrigger')
Expand Down Expand Up @@ -68,6 +79,13 @@ export function registerApmAlerts(
name: i18n.translate('xpack.apm.alertTypes.transactionErrorRate', {
defaultMessage: 'Transaction error rate threshold',
}),
description: i18n.translate(
'xpack.apm.alertTypes.transactionErrorRate.description',
{
defaultMessage:
'Alert when the rate of transaction errors in a service exceeds a defined threshold.',
}
),
iconClass: 'bell',
alertParamsExpression: lazy(
() => import('./TransactionErrorRateAlertTrigger')
Expand Down Expand Up @@ -95,6 +113,13 @@ export function registerApmAlerts(
name: i18n.translate('xpack.apm.alertTypes.transactionDurationAnomaly', {
defaultMessage: 'Transaction duration anomaly',
}),
description: i18n.translate(
'xpack.apm.alertTypes.transactionDurationAnomaly.description',
{
defaultMessage:
'Alert when the overall transaction duration of a service is considered anomalous.',
}
),
iconClass: 'bell',
alertParamsExpression: lazy(
() => import('./TransactionDurationAnomalyAlertTrigger')
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/infra/public/alerting/inventory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export function createInventoryMetricAlertType(): AlertTypeModel {
name: i18n.translate('xpack.infra.metrics.inventory.alertFlyout.alertName', {
defaultMessage: 'Inventory',
}),
description: i18n.translate('xpack.infra.metrics.inventory.alertFlyout.alertDescription', {
defaultMessage: 'Alert when the inventory exceeds a defined threshold.',
}),
iconClass: 'bell',
alertParamsExpression: React.lazy(() => import('./components/expression')),
validate: validateMetricThreshold,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export function getAlertType(): AlertTypeModel {
name: i18n.translate('xpack.infra.logs.alertFlyout.alertName', {
defaultMessage: 'Log threshold',
}),
description: i18n.translate('xpack.infra.logs.alertFlyout.alertDescription', {
defaultMessage: 'Alert when the log aggregation exceeds the threshold.',
}),
iconClass: 'bell',
alertParamsExpression: React.lazy(() => import('./components/expression_editor/editor')),
validate: validateExpression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export function createMetricThresholdAlertType(): AlertTypeModel {
name: i18n.translate('xpack.infra.metrics.alertFlyout.alertName', {
defaultMessage: 'Metric threshold',
}),
description: i18n.translate('xpack.infra.metrics.alertFlyout.alertDescription', {
defaultMessage: 'Alert when the metrics aggregation exceeds the threshold.',
}),
iconClass: 'bell',
alertParamsExpression: React.lazy(() => import('./components/expression')),
validate: validateMetricThreshold,
Expand Down
41 changes: 41 additions & 0 deletions x-pack/plugins/monitoring/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,31 +260,52 @@ export const LEGACY_ALERT_DETAILS = {
label: i18n.translate('xpack.monitoring.alerts.clusterHealth.label', {
defaultMessage: 'Cluster health',
}),
description: i18n.translate('xpack.monitoring.alerts.clusterHealth.description', {
defaultMessage: 'Alert when the health of the cluster changes.',
}),
},
[ALERT_ELASTICSEARCH_VERSION_MISMATCH]: {
label: i18n.translate('xpack.monitoring.alerts.elasticsearchVersionMismatch.label', {
defaultMessage: 'Elasticsearch version mismatch',
}),
description: i18n.translate(
'xpack.monitoring.alerts.elasticsearchVersionMismatch.description',
{
defaultMessage: 'Alert when the cluster has multiple versions of Elasticsearch.',
}
),
},
[ALERT_KIBANA_VERSION_MISMATCH]: {
label: i18n.translate('xpack.monitoring.alerts.kibanaVersionMismatch.label', {
defaultMessage: 'Kibana version mismatch',
}),
description: i18n.translate('xpack.monitoring.alerts.kibanaVersionMismatch.description', {
defaultMessage: 'Alert when the cluser has multiple versions of Kibana.',
}),
},
[ALERT_LICENSE_EXPIRATION]: {
label: i18n.translate('xpack.monitoring.alerts.licenseExpiration.label', {
defaultMessage: 'License expiration',
}),
description: i18n.translate('xpack.monitoring.alerts.licenseExpiration.description', {
defaultMessage: 'Alert when the cluster license is about to expire.',
}),
},
[ALERT_LOGSTASH_VERSION_MISMATCH]: {
label: i18n.translate('xpack.monitoring.alerts.logstashVersionMismatch.label', {
defaultMessage: 'Logstash version mismatch',
}),
description: i18n.translate('xpack.monitoring.alerts.logstashVersionMismatch.description', {
defaultMessage: 'Alert when the cluster has multiple versions of Logstash.',
}),
},
[ALERT_NODES_CHANGED]: {
label: i18n.translate('xpack.monitoring.alerts.nodesChanged.label', {
defaultMessage: 'Nodes changed',
}),
description: i18n.translate('xpack.monitoring.alerts.nodesChanged.description', {
defaultMessage: 'Alert when adding, removing, or restarting a node.',
}),
},
};

Expand All @@ -296,6 +317,9 @@ export const ALERT_DETAILS = {
label: i18n.translate('xpack.monitoring.alerts.cpuUsage.label', {
defaultMessage: 'CPU Usage',
}),
description: i18n.translate('xpack.monitoring.alerts.cpuUsage.description', {
defaultMessage: 'Alert when the CPU load for a node is consistently high.',
}),
paramDetails: {
threshold: {
label: i18n.translate('xpack.monitoring.alerts.cpuUsage.paramDetails.threshold.label', {
Expand Down Expand Up @@ -329,6 +353,9 @@ export const ALERT_DETAILS = {
label: i18n.translate('xpack.monitoring.alerts.diskUsage.label', {
defaultMessage: 'Disk Usage',
}),
description: i18n.translate('xpack.monitoring.alerts.diskUsage.description', {
defaultMessage: 'Alert when the disk usage for a node is consistently high.',
}),
},
[ALERT_MEMORY_USAGE]: {
paramDetails: {
Expand All @@ -348,6 +375,9 @@ export const ALERT_DETAILS = {
label: i18n.translate('xpack.monitoring.alerts.memoryUsage.label', {
defaultMessage: 'Memory Usage (JVM)',
}),
description: i18n.translate('xpack.monitoring.alerts.memoryUsage.description', {
defaultMessage: 'Alert when a node reports high memory usage.',
}),
},
[ALERT_MISSING_MONITORING_DATA]: {
paramDetails: {
Expand All @@ -367,6 +397,9 @@ export const ALERT_DETAILS = {
label: i18n.translate('xpack.monitoring.alerts.missingData.label', {
defaultMessage: 'Missing monitoring data',
}),
description: i18n.translate('xpack.monitoring.alerts.missingData.description', {
defaultMessage: 'Alert when monitoring data is missing.',
}),
},
[ALERT_THREAD_POOL_SEARCH_REJECTIONS]: {
paramDetails: {
Expand All @@ -388,6 +421,10 @@ export const ALERT_DETAILS = {
defaultMessage: 'Thread pool {type} rejections',
values: { type: 'search' },
}),
description: i18n.translate('xpack.monitoring.alerts.searchThreadPoolRejections.description', {
defaultMessage:
'Alert when the number of rejections in the search thread pool exceeds the threshold.',
}),
},
[ALERT_THREAD_POOL_WRITE_REJECTIONS]: {
paramDetails: {
Expand All @@ -409,6 +446,10 @@ export const ALERT_DETAILS = {
defaultMessage: 'Thread pool {type} rejections',
values: { type: 'write' },
}),
description: i18n.translate('xpack.monitoring.alerts.writeThreadPoolRejections.description', {
defaultMessage:
'Alert when the number of rejections in the write thread pool exceeds the threshold.',
}),
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function createCpuUsageAlertType(): AlertTypeModel {
return {
id: ALERT_CPU_USAGE,
name: ALERT_DETAILS[ALERT_CPU_USAGE].label,
description: ALERT_DETAILS[ALERT_CPU_USAGE].description,
iconClass: 'bell',
alertParamsExpression: (props: Props) => (
<Expression {...props} paramDetails={ALERT_DETAILS[ALERT_CPU_USAGE].paramDetails} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function createDiskUsageAlertType(): AlertTypeModel {
return {
id: ALERT_DISK_USAGE,
name: ALERT_DETAILS[ALERT_DISK_USAGE].label,
description: ALERT_DETAILS[ALERT_DISK_USAGE].description,
iconClass: 'bell',
alertParamsExpression: (props: Props) => (
<Expression {...props} paramDetails={ALERT_DETAILS[ALERT_DISK_USAGE].paramDetails} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function createLegacyAlertTypes(): AlertTypeModel[] {
return {
id: legacyAlert,
name: LEGACY_ALERT_DETAILS[legacyAlert].label,
description: LEGACY_ALERT_DETAILS[legacyAlert].description,
iconClass: 'bell',
alertParamsExpression: () => (
<Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function createMemoryUsageAlertType(): AlertTypeModel {
return {
id: ALERT_MEMORY_USAGE,
name: ALERT_DETAILS[ALERT_MEMORY_USAGE].label,
description: ALERT_DETAILS[ALERT_MEMORY_USAGE].description,
iconClass: 'bell',
alertParamsExpression: (props: Props) => (
<Expression {...props} paramDetails={ALERT_DETAILS[ALERT_MEMORY_USAGE].paramDetails} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function createMissingMonitoringDataAlertType(): AlertTypeModel {
return {
id: ALERT_MISSING_MONITORING_DATA,
name: ALERT_DETAILS[ALERT_MISSING_MONITORING_DATA].label,
description: ALERT_DETAILS[ALERT_MISSING_MONITORING_DATA].description,
iconClass: 'bell',
alertParamsExpression: (props: any) => (
<Expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface ThreadPoolTypes {

interface ThreadPoolRejectionAlertDetails {
label: string;
description: string;
paramDetails: CommonAlertParamDetails;
}

Expand All @@ -28,6 +29,7 @@ export function createThreadPoolRejectionsAlertType(
return {
id: alertType,
name: threadPoolAlertDetails.label,
description: threadPoolAlertDetails.description,
iconClass: 'bell',
alertParamsExpression: (props: Props) => (
<>
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/monitoring/server/alerts/base_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { appendMetricbeatIndex } from '../lib/alerts/append_mb_index';
export class BaseAlert {
public type!: string;
public label!: string;
public description!: string;
public defaultThrottle: string = '1d';
public defaultInterval: string = '1m';
public rawAlert: Alert | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const WATCH_NAME = 'elasticsearch_cluster_status';
export class ClusterHealthAlert extends BaseAlert {
public type = ALERT_CLUSTER_HEALTH;
public label = LEGACY_ALERT_DETAILS[ALERT_CLUSTER_HEALTH].label;
public description = LEGACY_ALERT_DETAILS[ALERT_CLUSTER_HEALTH].description;
public isLegacy = true;

protected actionVariables = [
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/monitoring/server/alerts/cpu_usage_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface CpuUsageParams {
export class CpuUsageAlert extends BaseAlert {
public type = ALERT_CPU_USAGE;
public label = ALERT_DETAILS[ALERT_CPU_USAGE].label;
public description = ALERT_DETAILS[ALERT_CPU_USAGE].description;

protected defaultParams: CpuUsageParams = {
threshold: 85,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { appendMetricbeatIndex } from '../lib/alerts/append_mb_index';
export class DiskUsageAlert extends BaseAlert {
public type = ALERT_DISK_USAGE;
public label = ALERT_DETAILS[ALERT_DISK_USAGE].label;
public description = ALERT_DETAILS[ALERT_DISK_USAGE].description;

protected defaultParams = {
threshold: 80,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const WATCH_NAME = 'elasticsearch_version_mismatch';
export class ElasticsearchVersionMismatchAlert extends BaseAlert {
public type = ALERT_ELASTICSEARCH_VERSION_MISMATCH;
public label = LEGACY_ALERT_DETAILS[ALERT_ELASTICSEARCH_VERSION_MISMATCH].label;
public description = LEGACY_ALERT_DETAILS[ALERT_ELASTICSEARCH_VERSION_MISMATCH].description;
public isLegacy = true;

protected actionVariables = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const WATCH_NAME = 'kibana_version_mismatch';
export class KibanaVersionMismatchAlert extends BaseAlert {
public type = ALERT_KIBANA_VERSION_MISMATCH;
public label = LEGACY_ALERT_DETAILS[ALERT_KIBANA_VERSION_MISMATCH].label;
public description = LEGACY_ALERT_DETAILS[ALERT_KIBANA_VERSION_MISMATCH].description;
public isLegacy = true;

protected actionVariables = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const WATCH_NAME = 'xpack_license_expiration';
export class LicenseExpirationAlert extends BaseAlert {
public type = ALERT_LICENSE_EXPIRATION;
public label = LEGACY_ALERT_DETAILS[ALERT_LICENSE_EXPIRATION].label;
public description = LEGACY_ALERT_DETAILS[ALERT_LICENSE_EXPIRATION].description;
public isLegacy = true;
protected actionVariables = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const WATCH_NAME = 'logstash_version_mismatch';
export class LogstashVersionMismatchAlert extends BaseAlert {
public type = ALERT_LOGSTASH_VERSION_MISMATCH;
public label = LEGACY_ALERT_DETAILS[ALERT_LOGSTASH_VERSION_MISMATCH].label;
public description = LEGACY_ALERT_DETAILS[ALERT_LOGSTASH_VERSION_MISMATCH].description;
public isLegacy = true;

protected actionVariables = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { parseDuration } from '../../../alerts/common/parse_duration';
export class MemoryUsageAlert extends BaseAlert {
public type = ALERT_MEMORY_USAGE;
public label = ALERT_DETAILS[ALERT_MEMORY_USAGE].label;
public description = ALERT_DETAILS[ALERT_MEMORY_USAGE].description;

protected defaultParams = {
threshold: 85,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class MissingMonitoringDataAlert extends BaseAlert {

public type = ALERT_MISSING_MONITORING_DATA;
public label = ALERT_DETAILS[ALERT_MISSING_MONITORING_DATA].label;
public description = ALERT_DETAILS[ALERT_MISSING_MONITORING_DATA].description;

protected defaultParams: MissingDataParams = {
duration: DEFAULT_DURATION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const WATCH_NAME = 'elasticsearch_nodes';
export class NodesChangedAlert extends BaseAlert {
public type = ALERT_NODES_CHANGED;
public label = LEGACY_ALERT_DETAILS[ALERT_NODES_CHANGED].label;
public description = LEGACY_ALERT_DETAILS[ALERT_NODES_CHANGED].description;
public isLegacy = true;

protected actionVariables = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export function getAlertType(): AlertTypeModel<GeoThresholdAlertParams, AlertsCo
name: i18n.translate('xpack.triggersActionsUI.geoThreshold.name.trackingThreshold', {
defaultMessage: 'Tracking threshold',
}),
description: i18n.translate('xpack.triggersActionsUI.geoThreshold.descriptionText', {
defaultMessage: 'Alert when an entity enters or leaves a geo boundary.',
}),
iconClass: 'globe',
alertParamsExpression: lazy(() => import('./query_builder')),
validate: validateExpression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { lazy } from 'react';
import { i18n } from '@kbn/i18n';

import { AlertTypeModel } from '../../../../types';
import { validateExpression } from './validation';
Expand All @@ -13,7 +14,12 @@ import { AlertsContextValue } from '../../../context/alerts_context';
export function getAlertType(): AlertTypeModel<IndexThresholdAlertParams, AlertsContextValue> {
return {
id: '.index-threshold',
name: 'Index threshold',
name: i18n.translate('xpack.triggersActionsUI.indexThresholdAlert.nameText', {
defaultMessage: 'Index threshold',
}),
description: i18n.translate('xpack.triggersActionsUI.indexThresholdAlert.descriptionText', {
defaultMessage: 'Alert when an aggregated query meets the threshold.',
}),
iconClass: 'alert',
alertParamsExpression: lazy(() => import('./expression')),
validate: validateExpression,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ describe('alert_add', () => {
id: 'my-alert-type',
iconClass: 'test',
name: 'test-alert',
description: 'test',
validate: (): ValidationResult => {
return { errors: {} };
},
Expand Down
Loading

0 comments on commit b0d7421

Please sign in to comment.