From 819d80a649dbcc6d7faf88f92b1f58039002ebe1 Mon Sep 17 00:00:00 2001 From: Valentin Crettaz Date: Fri, 11 Oct 2024 16:06:45 +0200 Subject: [PATCH] [Monitoring] Improved "Nodes changed" rule alert message (#195699) Closes https://github.com/elastic/kibana/issues/195533 ## Summary This PR fixes the format of the message of the Stack Monitoring built-in "Nodes changed" alert to be less confusing. The message now lists the added/removed/restarted nodes in a clearer fashion. Instead of ``` Nodes changed alert is firing for cluster-name-xyz (abc123). The following Elasticsearch nodes have been added: removed: instance-0000000012 restarted. ``` The message now shows like ``` Nodes changed alert is firing for cluster-name-xyz (abc123). The following Elasticsearch nodes have been added: none / removed: instance-0000000012 / restarted: none ``` ### Checklist - [X] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [X] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) - [X] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) --- .../monitoring/server/rules/nodes_changed_rule.test.ts | 8 ++++---- .../plugins/monitoring/server/rules/nodes_changed_rule.ts | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/monitoring/server/rules/nodes_changed_rule.test.ts b/x-pack/plugins/monitoring/server/rules/nodes_changed_rule.test.ts index 3abd163343e9e..206e9f2dc042e 100644 --- a/x-pack/plugins/monitoring/server/rules/nodes_changed_rule.test.ts +++ b/x-pack/plugins/monitoring/server/rules/nodes_changed_rule.test.ts @@ -202,11 +202,11 @@ describe('NodesChangedAlert', () => { action: '[View nodes](elasticsearch/nodes)', actionPlain: 'Verify that you added, removed, or restarted nodes.', internalFullMessage: - 'Nodes changed alert is firing for testCluster. The following Elasticsearch nodes have been added: removed: restarted:test. [View nodes](elasticsearch/nodes)', + 'Nodes changed alert is firing for testCluster. The following Elasticsearch nodes have been added: none / removed: none / restarted: test. [View nodes](elasticsearch/nodes)', internalShortMessage: 'Nodes changed alert is firing for testCluster. Verify that you added, removed, or restarted nodes.', - added: '', - removed: '', + added: 'none', + removed: 'none', restarted: 'test', clusterName, state: 'firing', @@ -287,7 +287,7 @@ describe('NodesChangedAlert', () => { action: '[View nodes](elasticsearch/nodes)', actionPlain: 'Verify that you added, removed, or restarted nodes.', internalFullMessage: - 'Nodes changed alert is firing for testCluster. The following Elasticsearch nodes have been added:newNodeName removed:removedNodeName restarted:test. [View nodes](elasticsearch/nodes)', + 'Nodes changed alert is firing for testCluster. The following Elasticsearch nodes have been added: newNodeName / removed: removedNodeName / restarted: test. [View nodes](elasticsearch/nodes)', internalShortMessage: 'Nodes changed alert is firing for testCluster. Verify that you added, removed, or restarted nodes.', added: 'newNodeName', diff --git a/x-pack/plugins/monitoring/server/rules/nodes_changed_rule.ts b/x-pack/plugins/monitoring/server/rules/nodes_changed_rule.ts index 54edc90e16b7b..dc7a133f0d2ad 100644 --- a/x-pack/plugins/monitoring/server/rules/nodes_changed_rule.ts +++ b/x-pack/plugins/monitoring/server/rules/nodes_changed_rule.ts @@ -203,9 +203,9 @@ export class NodesChangedRule extends BaseRule { }); const action = `[${fullActionText}](elasticsearch/nodes)`; const states = getNodeStates(nodes); - const added = states.added.map((node) => node.nodeName).join(','); - const removed = states.removed.map((node) => node.nodeName).join(','); - const restarted = states.restarted.map((node) => node.nodeName).join(','); + const added = states.added.map((node) => node.nodeName).join(',') || 'none'; + const removed = states.removed.map((node) => node.nodeName).join(',') || 'none'; + const restarted = states.restarted.map((node) => node.nodeName).join(',') || 'none'; const internalShortMessage = i18n.translate( 'xpack.monitoring.alerts.nodesChanged.firing.internalShortMessage', { @@ -223,7 +223,7 @@ export class NodesChangedRule extends BaseRule { internalFullMessage: i18n.translate( 'xpack.monitoring.alerts.nodesChanged.firing.internalFullMessage', { - defaultMessage: `Nodes changed alert is firing for {clusterName}. The following Elasticsearch nodes have been added:{added} removed:{removed} restarted:{restarted}. {action}`, + defaultMessage: `Nodes changed alert is firing for {clusterName}. The following Elasticsearch nodes have been added: {added} / removed: {removed} / restarted: {restarted}. {action}`, values: { clusterName: cluster.clusterName, added,