-
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] Enable OOTB alerts in RAC page and multiple rules of a rule type #106457
[Stack Monitoring] Enable OOTB alerts in RAC page and multiple rules of a rule type #106457
Conversation
@@ -566,7 +566,7 @@ export const ALERT_ACTION_TYPE_LOG = '.server-log'; | |||
/** | |||
* To enable modifing of alerts in under actions | |||
*/ | |||
export const ALERT_REQUIRES_APP_CONTEXT = true; | |||
export const ALERT_REQUIRES_APP_CONTEXT = false; |
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.
allows rules to be managed in Stack Management -> RAC
CommonAlert, | ||
CommonAlertState, | ||
CommonAlertStatus, | ||
} from '../../../common/types/alerts'; | ||
import { PanelItem } from '../types'; | ||
import { sortByNewestAlert } from './sort_by_newest_alert'; | ||
import { Legacy } from '../../legacy_shims'; | ||
|
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.
This view creates the nested alerts menu when clicking on the badges. It's very confusing but I tried to get rid of some for loops and add some types. The logic change is that it's accommodating the fact that there can be more than one type of a rule and we should show them both in the menu.
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.
Agreed that it's still very confusing. I would like to pull it apart more but not during this PR. For now, can we rename alerts
on the incoming getAlertPanelsByCategory
function, to something that is more descriptive? It's really hard to keep track of what "alerts" means at any given time.
Also, can we add a bunch of comments for now about what these functions are doing step by step?
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.
I was playing around with the code to see if I could understand it better. This is where I ended up: https://gist.github.com/jasonrhodes/a6ad54b808943d46f85082df2bbfb200
I don't think we should do any of that right now, or ever necessarily. I think what you've done here is a good step for what we need right now, but if you look that over it may help you see where some comments might be useful based on how badly I've misunderstood some things, etc.
menu.push({ | ||
...category, | ||
alerts: alertsInCategory.map(({ alertName }) => { | ||
const alertStatus = alertsContext.allAlerts[alertName]; |
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.
I don't see the point in using the alertsContext which has a list of the OOTB alerts to get the instance there since we fetch for the same data at an interval and it exists in the component state.
alertTypeId: ALERT_NODES_CHANGED, | ||
name: `${ALERT_NODES_CHANGED}_label_2`, | ||
...mockAlert, | ||
}, |
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.
Add a rule of the same rule type and except that rule to be shown.
count: 0, | ||
}; | ||
alertsByNodes[state.nodeId][alertId].count++; | ||
alertsByNodes[state.nodeId][alertId].states.push(alertState); |
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.
groups by alertId (rule id - unique UUID) instead of alertTypeId (eg: monitoring_cpu_usage) which can now happen twice due to support of multiple types of rules allowed.
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.
Perfect, thanks.
const alertExists = alertTypeIds.find( | ||
(name) => alerts[name] && alerts[name].find((rule) => rule.states.length > 0) | ||
); | ||
return inSetupMode || alertExists; |
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.
search in all types of rules
return cnt; | ||
}, 0); | ||
return cnt; | ||
}, 0); |
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.
count rules for all types of rules. flatten first, then reduce.
id: 1, | ||
}, | ||
{ | ||
id: 2, |
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.
add test for returning multiple rules of a type instead of expecting only 1
|
||
const [rawAlert] = alertClientAlerts.data as [Alert]; | ||
return new alertCls(rawAlert) as BaseAlert; | ||
return alertClientAlerts.data.map((alert) => new alertCls(alert as Alert) as BaseAlert); |
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.
return all the rules of a type instead of the first one
{ | ||
rawAlert: { id: 2 }, | ||
states: [], | ||
}, |
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.
expect more than one rule per rule type to be returned
Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui) |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
LGTM if we can add a few renames/comments in the bulky part of this code path.
CommonAlert, | ||
CommonAlertState, | ||
CommonAlertStatus, | ||
} from '../../../common/types/alerts'; | ||
import { PanelItem } from '../types'; | ||
import { sortByNewestAlert } from './sort_by_newest_alert'; | ||
import { Legacy } from '../../legacy_shims'; | ||
|
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.
Agreed that it's still very confusing. I would like to pull it apart more but not during this PR. For now, can we rename alerts
on the incoming getAlertPanelsByCategory
function, to something that is more descriptive? It's really hard to keep track of what "alerts" means at any given time.
Also, can we add a bunch of comments for now about what these functions are doing step by step?
CommonAlert, | ||
CommonAlertState, | ||
CommonAlertStatus, | ||
} from '../../../common/types/alerts'; | ||
import { PanelItem } from '../types'; | ||
import { sortByNewestAlert } from './sort_by_newest_alert'; | ||
import { Legacy } from '../../legacy_shims'; | ||
|
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.
I was playing around with the code to see if I could understand it better. This is where I ended up: https://gist.github.com/jasonrhodes/a6ad54b808943d46f85082df2bbfb200
I don't think we should do any of that right now, or ever necessarily. I think what you've done here is a good step for what we need right now, but if you look that over it may help you see where some comments might be useful based on how badly I've misunderstood some things, etc.
count: 0, | ||
}; | ||
alertsByNodes[state.nodeId][alertId].count++; | ||
alertsByNodes[state.nodeId][alertId].states.push(alertState); |
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.
Perfect, thanks.
595bf99
to
d9b279a
Compare
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
…of a rule type (elastic#106457) * allow rules to be managed in RAC page * return all rules of a rule type instead of first one * update UI to handle multiple rule types * add comments about creating the menus by category for alerts and rules * fix parsing of cluster alerts
…of a rule type (elastic#106457) * allow rules to be managed in RAC page * return all rules of a rule type instead of first one * update UI to handle multiple rule types * add comments about creating the menus by category for alerts and rules * fix parsing of cluster alerts
Summary
Resolves #91145
Resolves #100142
Resolves #92128
Test