-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Stack Monitoring] create alert per node, index, or cluster instead of always per cluster #102544
Merged
neptunian
merged 21 commits into
elastic:master
from
neptunian:100136-alerts-per-node-change-stack-monitoring
Jun 29, 2021
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
8958485
create alert per node instead of per cluster
neptunian 78ccc94
add comment
neptunian 78882c6
fix test, replace alert state with empty array with no node is firing
neptunian b7fd890
update cpu usage action messaging
neptunian b0af3fe
fix internationalization
neptunian d610744
update disk usage rule action messaging
neptunian 215e5ac
update memory usage rule action messaging
neptunian 8087080
update other action messaging
neptunian 2b1bf65
update missing monitoring data alert action messaging
neptunian 42f06e8
remove comment
neptunian 394369e
fix bug where threadpool alerts were not firing
neptunian 853725c
fix bug with threadpool rejections and update alert action messaging …
neptunian 65fe38b
update comments
neptunian 4957b68
unit test for thread pool write rejections alert
neptunian c71347c
update messaging for CCR read rejection
neptunian ded697e
fix cluster level alerts to use the cluster id when its not node level
neptunian f9b57cd
add more tests to nodes changed alert
neptunian 5c9f377
update default message
neptunian 6cb2c0d
update alert messaging for large shard size
neptunian f3034ca
update default messaging
neptunian 0a0b773
Merge branch 'master' into 100136-alerts-per-node-change-stack-monito…
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,46 +274,49 @@ export class BaseAlert { | |
state: ExecutedState | ||
) { | ||
const currentUTC = +new Date(); | ||
// for each cluster filter the nodes that belong to this cluster | ||
for (const cluster of clusters) { | ||
const nodes = data.filter((node) => node.clusterUuid === cluster.clusterUuid); | ||
if (!nodes.length) { | ||
continue; | ||
} | ||
|
||
const firingNodeUuids = nodes | ||
.filter((node) => node.shouldFire) | ||
.map((node) => node.meta.nodeId || node.meta.instanceId) | ||
.join(','); | ||
const instanceId = `${this.alertOptions.id}:${cluster.clusterUuid}:${firingNodeUuids}`; | ||
const instance = services.alertInstanceFactory(instanceId); | ||
const newAlertStates: AlertNodeState[] = []; | ||
const key = this.alertOptions.accessorKey; | ||
|
||
// for each node, update the alert's state with node state | ||
for (const node of nodes) { | ||
if (!node.shouldFire) { | ||
continue; | ||
const newAlertStates: AlertNodeState[] = []; | ||
// quick fix for now so that non node level alerts will use the cluster id | ||
const instance = services.alertInstanceFactory( | ||
node.meta.nodeId || node.meta.instanceId || cluster.clusterUuid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some alerts are cluster level and do not have a nodeId or instanceId property, so use the clusterUuid. This should be typed and improved at some point or have a different function for cluster vs node level processing. |
||
); | ||
|
||
if (node.shouldFire) { | ||
const { meta } = node; | ||
// create a default alert state for this node and add data from node.meta and other data | ||
const nodeState = this.getDefaultAlertState(cluster, node) as AlertNodeState; | ||
if (key) { | ||
nodeState[key] = meta[key]; | ||
} | ||
nodeState.nodeId = meta.nodeId || node.nodeId! || meta.instanceId; | ||
// TODO: make these functions more generic, so it's node/item agnostic | ||
nodeState.nodeName = meta.itemLabel || meta.nodeName || node.nodeName || nodeState.nodeId; | ||
nodeState.itemLabel = meta.itemLabel; | ||
nodeState.meta = meta; | ||
nodeState.ui.triggeredMS = currentUTC; | ||
nodeState.ui.isFiring = true; | ||
nodeState.ui.severity = node.severity; | ||
nodeState.ui.message = this.getUiMessage(nodeState, node); | ||
// store the state of each node in array. | ||
newAlertStates.push(nodeState); | ||
} | ||
const { meta } = node; | ||
const nodeState = this.getDefaultAlertState(cluster, node) as AlertNodeState; | ||
if (key) { | ||
nodeState[key] = meta[key]; | ||
const alertInstanceState = { alertStates: newAlertStates }; | ||
// update the alert's state with the new node states | ||
instance.replaceState(alertInstanceState); | ||
if (newAlertStates.length) { | ||
this.executeActions(instance, alertInstanceState, null, cluster); | ||
state.lastExecutedAction = currentUTC; | ||
} | ||
nodeState.nodeId = meta.nodeId || node.nodeId! || meta.instanceId; | ||
// TODO: make these functions more generic, so it's node/item agnostic | ||
nodeState.nodeName = meta.itemLabel || meta.nodeName || node.nodeName || nodeState.nodeId; | ||
nodeState.itemLabel = meta.itemLabel; | ||
nodeState.meta = meta; | ||
nodeState.ui.triggeredMS = currentUTC; | ||
nodeState.ui.isFiring = true; | ||
nodeState.ui.severity = node.severity; | ||
nodeState.ui.message = this.getUiMessage(nodeState, node); | ||
newAlertStates.push(nodeState); | ||
} | ||
|
||
const alertInstanceState = { alertStates: newAlertStates }; | ||
instance.replaceState(alertInstanceState); | ||
if (newAlertStates.length) { | ||
this.executeActions(instance, alertInstanceState, null, cluster); | ||
state.lastExecutedAction = currentUTC; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is where I've moved the triggering of the new alert into the inner for loop that loops through each node, instead of in the cluster for loop.