Skip to content

Commit

Permalink
[Stack Monitoring] Rename alerts to rules (#107654)
Browse files Browse the repository at this point in the history
* rename constants and alert types to rules

* update test language

* update BaseRule properties to rule

* change rawAlert to sanitizedRule

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
neptunian and kibanamachine authored Aug 10, 2021
1 parent faf6482 commit bc25c0f
Show file tree
Hide file tree
Showing 72 changed files with 798 additions and 817 deletions.
162 changes: 81 additions & 81 deletions x-pack/plugins/monitoring/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,37 +220,37 @@ export const CLUSTER_DETAILS_FETCH_INTERVAL = 10800000;
export const USAGE_FETCH_INTERVAL = 1200000;

/**
* The prefix for all alert types used by monitoring
*/
export const ALERT_PREFIX = 'monitoring_';
export const ALERT_LICENSE_EXPIRATION = `${ALERT_PREFIX}alert_license_expiration`;
export const ALERT_CLUSTER_HEALTH = `${ALERT_PREFIX}alert_cluster_health`;
export const ALERT_CPU_USAGE = `${ALERT_PREFIX}alert_cpu_usage`;
export const ALERT_DISK_USAGE = `${ALERT_PREFIX}alert_disk_usage`;
export const ALERT_NODES_CHANGED = `${ALERT_PREFIX}alert_nodes_changed`;
export const ALERT_ELASTICSEARCH_VERSION_MISMATCH = `${ALERT_PREFIX}alert_elasticsearch_version_mismatch`;
export const ALERT_KIBANA_VERSION_MISMATCH = `${ALERT_PREFIX}alert_kibana_version_mismatch`;
export const ALERT_LOGSTASH_VERSION_MISMATCH = `${ALERT_PREFIX}alert_logstash_version_mismatch`;
export const ALERT_MEMORY_USAGE = `${ALERT_PREFIX}alert_jvm_memory_usage`;
export const ALERT_MISSING_MONITORING_DATA = `${ALERT_PREFIX}alert_missing_monitoring_data`;
export const ALERT_THREAD_POOL_SEARCH_REJECTIONS = `${ALERT_PREFIX}alert_thread_pool_search_rejections`;
export const ALERT_THREAD_POOL_WRITE_REJECTIONS = `${ALERT_PREFIX}alert_thread_pool_write_rejections`;
export const ALERT_CCR_READ_EXCEPTIONS = `${ALERT_PREFIX}ccr_read_exceptions`;
export const ALERT_LARGE_SHARD_SIZE = `${ALERT_PREFIX}shard_size`;
* The prefix for all rule types used by monitoring
*/
export const RULE_PREFIX = 'monitoring_';
export const RULE_LICENSE_EXPIRATION = `${RULE_PREFIX}alert_license_expiration`;
export const RULE_CLUSTER_HEALTH = `${RULE_PREFIX}alert_cluster_health`;
export const RULE_CPU_USAGE = `${RULE_PREFIX}alert_cpu_usage`;
export const RULE_DISK_USAGE = `${RULE_PREFIX}alert_disk_usage`;
export const RULE_NODES_CHANGED = `${RULE_PREFIX}alert_nodes_changed`;
export const RULE_ELASTICSEARCH_VERSION_MISMATCH = `${RULE_PREFIX}alert_elasticsearch_version_mismatch`;
export const RULE_KIBANA_VERSION_MISMATCH = `${RULE_PREFIX}alert_kibana_version_mismatch`;
export const RULE_LOGSTASH_VERSION_MISMATCH = `${RULE_PREFIX}alert_logstash_version_mismatch`;
export const RULE_MEMORY_USAGE = `${RULE_PREFIX}alert_jvm_memory_usage`;
export const RULE_MISSING_MONITORING_DATA = `${RULE_PREFIX}alert_missing_monitoring_data`;
export const RULE_THREAD_POOL_SEARCH_REJECTIONS = `${RULE_PREFIX}alert_thread_pool_search_rejections`;
export const RULE_THREAD_POOL_WRITE_REJECTIONS = `${RULE_PREFIX}alert_thread_pool_write_rejections`;
export const RULE_CCR_READ_EXCEPTIONS = `${RULE_PREFIX}ccr_read_exceptions`;
export const RULE_LARGE_SHARD_SIZE = `${RULE_PREFIX}shard_size`;

/**
* Legacy alerts details/label for server and public use
* Legacy rules details/label for server and public use
*/
export const LEGACY_ALERT_DETAILS = {
[ALERT_CLUSTER_HEALTH]: {
export const LEGACY_RULE_DETAILS = {
[RULE_CLUSTER_HEALTH]: {
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]: {
[RULE_ELASTICSEARCH_VERSION_MISMATCH]: {
label: i18n.translate('xpack.monitoring.alerts.elasticsearchVersionMismatch.label', {
defaultMessage: 'Elasticsearch version mismatch',
}),
Expand All @@ -261,31 +261,31 @@ export const LEGACY_ALERT_DETAILS = {
}
),
},
[ALERT_KIBANA_VERSION_MISMATCH]: {
[RULE_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]: {
[RULE_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]: {
[RULE_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]: {
[RULE_NODES_CHANGED]: {
label: i18n.translate('xpack.monitoring.alerts.nodesChanged.label', {
defaultMessage: 'Nodes changed',
}),
Expand All @@ -296,10 +296,10 @@ export const LEGACY_ALERT_DETAILS = {
};

/**
* Alerts details/label for server and public use
* Rules details/label for server and public use
*/
export const ALERT_DETAILS = {
[ALERT_CPU_USAGE]: {
export const RULE_DETAILS = {
[RULE_CPU_USAGE]: {
label: i18n.translate('xpack.monitoring.alerts.cpuUsage.label', {
defaultMessage: 'CPU Usage',
}),
Expand All @@ -321,7 +321,7 @@ export const ALERT_DETAILS = {
} as CommonAlertParamDetail,
},
},
[ALERT_DISK_USAGE]: {
[RULE_DISK_USAGE]: {
paramDetails: {
threshold: {
label: i18n.translate('xpack.monitoring.alerts.diskUsage.paramDetails.threshold.label', {
Expand All @@ -343,7 +343,7 @@ export const ALERT_DETAILS = {
defaultMessage: 'Alert when the disk usage for a node is consistently high.',
}),
},
[ALERT_MEMORY_USAGE]: {
[RULE_MEMORY_USAGE]: {
paramDetails: {
threshold: {
label: i18n.translate('xpack.monitoring.alerts.memoryUsage.paramDetails.threshold.label', {
Expand All @@ -365,7 +365,7 @@ export const ALERT_DETAILS = {
defaultMessage: 'Alert when a node reports high memory usage.',
}),
},
[ALERT_MISSING_MONITORING_DATA]: {
[RULE_MISSING_MONITORING_DATA]: {
paramDetails: {
duration: {
label: i18n.translate('xpack.monitoring.alerts.missingData.paramDetails.duration.label', {
Expand All @@ -387,7 +387,7 @@ export const ALERT_DETAILS = {
defaultMessage: 'Alert when monitoring data is missing.',
}),
},
[ALERT_THREAD_POOL_SEARCH_REJECTIONS]: {
[RULE_THREAD_POOL_SEARCH_REJECTIONS]: {
paramDetails: {
threshold: {
label: i18n.translate('xpack.monitoring.alerts.rejection.paramDetails.threshold.label', {
Expand All @@ -412,7 +412,7 @@ export const ALERT_DETAILS = {
'Alert when the number of rejections in the search thread pool exceeds the threshold.',
}),
},
[ALERT_THREAD_POOL_WRITE_REJECTIONS]: {
[RULE_THREAD_POOL_WRITE_REJECTIONS]: {
paramDetails: {
threshold: {
label: i18n.translate('xpack.monitoring.alerts.rejection.paramDetails.threshold.label', {
Expand All @@ -437,7 +437,7 @@ export const ALERT_DETAILS = {
'Alert when the number of rejections in the write thread pool exceeds the threshold.',
}),
},
[ALERT_CCR_READ_EXCEPTIONS]: {
[RULE_CCR_READ_EXCEPTIONS]: {
paramDetails: {
duration: {
label: i18n.translate(
Expand All @@ -456,7 +456,7 @@ export const ALERT_DETAILS = {
defaultMessage: 'Alert if any CCR read exceptions have been detected.',
}),
},
[ALERT_LARGE_SHARD_SIZE]: {
[RULE_LARGE_SHARD_SIZE]: {
paramDetails: {
threshold: {
label: i18n.translate('xpack.monitoring.alerts.shardSize.paramDetails.threshold.label', {
Expand All @@ -482,74 +482,74 @@ export const ALERT_DETAILS = {
},
};

export const ALERT_PANEL_MENU = [
export const RULE_PANEL_MENU = [
{
label: i18n.translate('xpack.monitoring.alerts.badge.panelCategory.clusterHealth', {
defaultMessage: 'Cluster health',
}),
alerts: [
{ alertName: ALERT_NODES_CHANGED },
{ alertName: ALERT_CLUSTER_HEALTH },
{ alertName: ALERT_ELASTICSEARCH_VERSION_MISMATCH },
{ alertName: ALERT_KIBANA_VERSION_MISMATCH },
{ alertName: ALERT_LOGSTASH_VERSION_MISMATCH },
rules: [
{ ruleName: RULE_NODES_CHANGED },
{ ruleName: RULE_CLUSTER_HEALTH },
{ ruleName: RULE_ELASTICSEARCH_VERSION_MISMATCH },
{ ruleName: RULE_KIBANA_VERSION_MISMATCH },
{ ruleName: RULE_LOGSTASH_VERSION_MISMATCH },
],
},
{
label: i18n.translate('xpack.monitoring.alerts.badge.panelCategory.resourceUtilization', {
defaultMessage: 'Resource utilization',
}),
alerts: [
{ alertName: ALERT_CPU_USAGE },
{ alertName: ALERT_DISK_USAGE },
{ alertName: ALERT_MEMORY_USAGE },
{ alertName: ALERT_LARGE_SHARD_SIZE },
rules: [
{ ruleName: RULE_CPU_USAGE },
{ ruleName: RULE_DISK_USAGE },
{ ruleName: RULE_MEMORY_USAGE },
{ ruleName: RULE_LARGE_SHARD_SIZE },
],
},
{
label: i18n.translate('xpack.monitoring.alerts.badge.panelCategory.errors', {
defaultMessage: 'Errors and exceptions',
}),
alerts: [
{ alertName: ALERT_MISSING_MONITORING_DATA },
{ alertName: ALERT_LICENSE_EXPIRATION },
{ alertName: ALERT_THREAD_POOL_SEARCH_REJECTIONS },
{ alertName: ALERT_THREAD_POOL_WRITE_REJECTIONS },
{ alertName: ALERT_CCR_READ_EXCEPTIONS },
rules: [
{ ruleName: RULE_MISSING_MONITORING_DATA },
{ ruleName: RULE_LICENSE_EXPIRATION },
{ ruleName: RULE_THREAD_POOL_SEARCH_REJECTIONS },
{ ruleName: RULE_THREAD_POOL_WRITE_REJECTIONS },
{ ruleName: RULE_CCR_READ_EXCEPTIONS },
],
},
];

/**
* A listing of all alert types
*/
export const ALERTS = [
ALERT_LICENSE_EXPIRATION,
ALERT_CLUSTER_HEALTH,
ALERT_CPU_USAGE,
ALERT_DISK_USAGE,
ALERT_NODES_CHANGED,
ALERT_ELASTICSEARCH_VERSION_MISMATCH,
ALERT_KIBANA_VERSION_MISMATCH,
ALERT_LOGSTASH_VERSION_MISMATCH,
ALERT_MEMORY_USAGE,
ALERT_MISSING_MONITORING_DATA,
ALERT_THREAD_POOL_SEARCH_REJECTIONS,
ALERT_THREAD_POOL_WRITE_REJECTIONS,
ALERT_CCR_READ_EXCEPTIONS,
ALERT_LARGE_SHARD_SIZE,
* A listing of all rule types
*/
export const RULES = [
RULE_LICENSE_EXPIRATION,
RULE_CLUSTER_HEALTH,
RULE_CPU_USAGE,
RULE_DISK_USAGE,
RULE_NODES_CHANGED,
RULE_ELASTICSEARCH_VERSION_MISMATCH,
RULE_KIBANA_VERSION_MISMATCH,
RULE_LOGSTASH_VERSION_MISMATCH,
RULE_MEMORY_USAGE,
RULE_MISSING_MONITORING_DATA,
RULE_THREAD_POOL_SEARCH_REJECTIONS,
RULE_THREAD_POOL_WRITE_REJECTIONS,
RULE_CCR_READ_EXCEPTIONS,
RULE_LARGE_SHARD_SIZE,
];

/**
* A list of all legacy alerts, which means they are powered by watcher
*/
export const LEGACY_ALERTS = [
ALERT_LICENSE_EXPIRATION,
ALERT_CLUSTER_HEALTH,
ALERT_NODES_CHANGED,
ALERT_ELASTICSEARCH_VERSION_MISMATCH,
ALERT_KIBANA_VERSION_MISMATCH,
ALERT_LOGSTASH_VERSION_MISMATCH,
* A list of all legacy rules, which means they are powered by watcher
*/
export const LEGACY_RULES = [
RULE_LICENSE_EXPIRATION,
RULE_CLUSTER_HEALTH,
RULE_NODES_CHANGED,
RULE_ELASTICSEARCH_VERSION_MISMATCH,
RULE_KIBANA_VERSION_MISMATCH,
RULE_LOGSTASH_VERSION_MISMATCH,
];

/**
Expand All @@ -564,9 +564,9 @@ export const ALERT_ACTION_TYPE_EMAIL = '.email';
export const ALERT_ACTION_TYPE_LOG = '.server-log';

/**
* To enable modifing of alerts in under actions
* To enable modifing of rules in under actions
*/
export const ALERT_REQUIRES_APP_CONTEXT = false;
export const RULE_REQUIRES_APP_CONTEXT = false;

export const ALERT_EMAIL_SERVICES = ['gmail', 'hotmail', 'icloud', 'outlook365', 'ses', 'yahoo'];

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/common/types/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface RulesByType {
}
export interface CommonAlertStatus {
states: CommonAlertState[];
rawAlert: Alert<AlertTypeParams> | SanitizedAlert<AlertTypeParams>;
sanitizedRule: Alert<AlertTypeParams> | SanitizedAlert<AlertTypeParams>;
}

export interface CommonAlertState {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/public/alerts/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const AlertsBadge: React.FC<Props> = (props: Props) => {
// We do not always have the alerts that each consumer wants due to licensing
const { stateFilter = () => true } = props;
const alertsList = Object.values(props.alerts).flat();
const alerts = alertsList.filter((alertItem) => Boolean(alertItem?.rawAlert));
const alerts = alertsList.filter((alertItem) => Boolean(alertItem?.sanitizedRule));
const [showPopover, setShowPopover] = React.useState<AlertSeverity | boolean | null>(null);
const inSetupMode = isInSetupMode(React.useContext(SetupModeContext));
const alertCount = inSetupMode
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/public/alerts/callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export const AlertsCallout: React.FC<Props> = (props: Props) => {
}
)}
<EuiListGroupItem
label={<AlertConfiguration alert={status.alert.rawAlert} key={index} compressed />}
label={<AlertConfiguration alert={status.alert.sanitizedRule} key={index} compressed />}
/>
</EuiListGroup>
</EuiAccordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { i18n } from '@kbn/i18n';
import { Expression, Props } from '../components/param_details_form/expression';
import { AlertTypeModel, ValidationResult } from '../../../../triggers_actions_ui/public';
import {
ALERT_CCR_READ_EXCEPTIONS,
ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
RULE_CCR_READ_EXCEPTIONS,
RULE_DETAILS,
RULE_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';
import { AlertTypeParams } from '../../../../alerting/common';

Expand All @@ -38,17 +38,17 @@ const validate = (inputValues: ValidateOptions): ValidationResult => {

export function createCCRReadExceptionsAlertType(): AlertTypeModel<ValidateOptions> {
return {
id: ALERT_CCR_READ_EXCEPTIONS,
description: ALERT_DETAILS[ALERT_CCR_READ_EXCEPTIONS].description,
id: RULE_CCR_READ_EXCEPTIONS,
description: RULE_DETAILS[RULE_CCR_READ_EXCEPTIONS].description,
iconClass: 'bell',
documentationUrl(docLinks) {
return `${docLinks.links.monitoring.alertsKibanaCCRReadExceptions}`;
},
alertParamsExpression: (props: Props) => (
<Expression {...props} paramDetails={ALERT_DETAILS[ALERT_CCR_READ_EXCEPTIONS].paramDetails} />
<Expression {...props} paramDetails={RULE_DETAILS[RULE_CCR_READ_EXCEPTIONS].paramDetails} />
),
validate,
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
requiresAppContext: RULE_REQUIRES_APP_CONTEXT,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,23 @@
import React from 'react';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types';
import {
ALERT_CPU_USAGE,
ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';
import { RULE_CPU_USAGE, RULE_DETAILS, RULE_REQUIRES_APP_CONTEXT } from '../../../common/constants';
import { validate, MonitoringAlertTypeParams } from '../components/param_details_form/validation';
import { Expression, Props } from '../components/param_details_form/expression';

export function createCpuUsageAlertType(): AlertTypeModel<MonitoringAlertTypeParams> {
return {
id: ALERT_CPU_USAGE,
description: ALERT_DETAILS[ALERT_CPU_USAGE].description,
id: RULE_CPU_USAGE,
description: RULE_DETAILS[RULE_CPU_USAGE].description,
iconClass: 'bell',
documentationUrl(docLinks) {
return `${docLinks.links.monitoring.alertsKibanaCpuThreshold}`;
},
alertParamsExpression: (props: Props) => (
<Expression {...props} paramDetails={ALERT_DETAILS[ALERT_CPU_USAGE].paramDetails} />
<Expression {...props} paramDetails={RULE_DETAILS[RULE_CPU_USAGE].paramDetails} />
),
validate,
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
requiresAppContext: RULE_REQUIRES_APP_CONTEXT,
};
}
Loading

0 comments on commit bc25c0f

Please sign in to comment.