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
Add Notifications coloumn in alerts table #5943
Add Notifications coloumn in alerts table #5943
Conversation
/hold |
edbe080
to
77d7338
Compare
/hold cancel |
/cc @cshinn |
77d7338
to
b5c5dc5
Compare
}; | ||
|
||
const SILENCE_FOR = 'Silence for '; | ||
const durations = [SILENCE_FOR, '30m', '1h', '2h', '6h', '12h', '1d', '2d', '1w']; |
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.
Mocks have dropdown labels like 30 minutes
, 1 hour
, etc.
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.
Done
isOpen: rls.state === RuleStates.Firing && !_.includes(collapsedRowsIds, rls.name), | ||
isOpen: | ||
(rls.state === RuleStates.Firing && !_.includes(collapsedRowsIds, rls.name)) || | ||
(rls.state !== RuleStates.Firing && _.includes(collapsedRowsIds, rls.name)), |
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.
Is this right? Shouldn't collapsed rows always be isOpen = 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.
yes, collapsed rows always be isOpen = false
. But when the user expands it should be expanded to handle this scenario I added this. I missed this scenario in my last PR.
const rows = []; | ||
_.forEach(alertrules, (rls) => { | ||
rows.push({ | ||
...(rls.state !== RuleStates.Inactive && { | ||
isOpen: rls.state === RuleStates.Firing && !_.includes(collapsedRowsIds, rls.name), | ||
isOpen: | ||
(rls.state === RuleStates.Firing && !_.includes(collapsedRowsIds, rls.name)) || |
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.
Not introduced by this PR, but it now occurs to me that using the rule name
as row key will fail if we have two rules with the same name
.
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.
Isn't alertname
is going to be unique for a namespace?
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.
Ah, I forgot this was constrained by namespace.
So, this is the same situation as our silence rule discussion. alertname
is not technically guaranteed to be unique even within a namespace, but in practice it almost certainly will be. I think this is acceptable for now, but we should probably have a more robust solution at some point.
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.
Fixed it, now I am using rules id instead of the name.
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.
👍
<Switch | ||
aria-label="Silence switch" | ||
className="odc-silence-alert" | ||
label="On" |
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 think you can just omit the label
prop. Then you don't need the .pf-c-switch__label.pf-m-on
display: none
CSS.
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.
To add labelOff
prop label
prop is required.
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.
Looks like you can set label
to null
, then you can still use labelOff
without needing the CSS.
b5c5dc5
to
822ebe3
Compare
7d8967e
to
83c6ab3
Compare
const { alertManagerBaseURL } = window.SERVER_FLAGS; | ||
|
||
const SilenceUntil = ({ rule }) => { | ||
if (alert && !_.isEmpty(rule.silencedBy)) { |
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 alert &&
looks unnecessary
const SilenceAlert: React.FC<SilenceAlertProps> = ({ rule, namespace }) => { | ||
const [isChecked, setIsChecked] = React.useState(true); | ||
React.useEffect( | ||
() => (rule.state === RuleStates.Silenced ? setIsChecked(false) : setIsChecked(true)), |
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.
() => (rule.state === RuleStates.Silenced ? setIsChecked(false) : setIsChecked(true)), | |
() => setIsChecked(rule.state !== RuleStates.Silenced) |
const SilenceDurationDropDown: React.FC<SilenceDurationDropDownProps> = ({ rule, namespace }) => { | ||
const createdBy = useSelector((state: RootState) => state.UI.get('user')?.metadata?.name); | ||
|
||
const matchers = [ |
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.
Should also add matchers for any additional labels found in rule.labels
.
frontend/public/reducers/ui.ts
Outdated
@@ -59,6 +59,26 @@ const silenceFiringAlerts = (firingAlerts, silences) => { | |||
}); | |||
}; | |||
|
|||
const silenceFiringRules = (firingRules, silences) => { |
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.
Looks like we can make this much simper by removing silenceFiringRules
and leaving MonitoringSetRules
unchanged. Then modify silenceFiringAlerts
instead.
silenceFiringAlerts
is already being run when the rules are imported, and already does much of the work to determine which alerts are silenced.
Modify silenceFiringAlerts
by adding the following (or something similar) inside the if (a.silencedBy.length) { ... }
block.
if (!_.isEmpty(a.rule.alerts) && _.every(a.rule.alerts, isSilenced)) {
a.rule.state = RuleStates.Silenced;
a.rule.silencedBy = _.filter(
silences?.data,
(s) => s.status.state === SilenceStates.Active && _.some(a.rule.alerts, isSilenced),
);
}
(briefly tested, but not properly)
83c6ab3
to
2fdaac6
Compare
dd80f04
to
f08f969
Compare
const ruleLabelKeys = _.keys(rule?.labels); | ||
const ruleLabelValues = _.values(rule?.labels); | ||
const ruleMatchers = _.zipWith(ruleLabelKeys, ruleLabelValues, (key, value) => { | ||
return { name: key, value, isRegex: 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.
const ruleLabelKeys = _.keys(rule?.labels); | |
const ruleLabelValues = _.values(rule?.labels); | |
const ruleMatchers = _.zipWith(ruleLabelKeys, ruleLabelValues, (key, value) => { | |
return { name: key, value, isRegex: false }; | |
}); | |
const ruleMatchers = _.map(rule?.labels, (value, key) => ({ isRegex: false, name: key, value })); |
f08f969
to
95b66b5
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: kyoto, vikram-raj The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Story - https://issues.redhat.com/browse/ODC-4119
Description
This PR
Screenshots
Test setup:
It will create a rule and an alert for the same rule in
ns1
namespace