From b2f7ea6651545863e32832d78cb0b8cb72089737 Mon Sep 17 00:00:00 2001 From: consulthys Date: Thu, 10 Oct 2024 06:12:28 +0200 Subject: [PATCH 1/2] Improve "Nodes changed" rule alert message --- .../monitoring/server/rules/nodes_changed_rule.test.ts | 4 ++-- .../plugins/monitoring/server/rules/nodes_changed_rule.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 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..83600dbd23f4d 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,7 +202,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: 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: '', @@ -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, From e9fce3493f79b40bb87dd124503b0dfe143fffe7 Mon Sep 17 00:00:00 2001 From: consulthys Date: Thu, 10 Oct 2024 08:09:06 +0200 Subject: [PATCH 2/2] Improve "Nodes changed" rule alert message (fixed unit tests) --- .../monitoring/server/rules/nodes_changed_rule.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 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 83600dbd23f4d..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 @@ -205,8 +205,8 @@ describe('NodesChangedAlert', () => { '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',