-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
#3513: Show muted alerts in the Alert Groups API #3797
base: main
Are you sure you want to change the base?
#3513: Show muted alerts in the Alert Groups API #3797
Conversation
5c4b023
to
ce8652d
Compare
3de4eba
to
08836ab
Compare
ui/app/src/Alerts/Api.elm
Outdated
fetchAlerts apiUrl filter = | ||
let | ||
url = | ||
String.join "/" [ apiUrl, "alerts" ++ generateAPIQueryString filter ] | ||
in | ||
Utils.Api.send (Utils.Api.get url (Json.Decode.list Data.GettableAlert.decoder)) | ||
Utils.Api.send (Utils.Api.get url (Json.Decode.list Data.ExtendedGettableAlert.decoder)) |
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 is the most important change to the Elm code. I'm decoding the response for /api/v2/alerts
as ExtendedGettableAlert
when in the OpenAPI schema it is GettableAlert
. The difference between the two is that ExtendedGettableAlert
has a mutedBy
column in status
.
08836ab
to
681f2a7
Compare
681f2a7
to
1d227f1
Compare
0c1a5f8
to
0cd1216
Compare
@@ -86,16 +88,18 @@ type ( | |||
func NewAPI( | |||
alerts provider.Alerts, | |||
gf groupsFn, | |||
sf getAlertStatusFn, | |||
asf getAlertStatusFn, |
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 the best variable name, option to suggestions! 😄
@@ -407,17 +411,22 @@ func (api *API) getAlertGroupsHandler(params alertgroup_ops.GetAlertGroupsParams | |||
res := make(open_api_models.AlertGroups, 0, len(alertGroups)) | |||
|
|||
for _, alertGroup := range alertGroups { | |||
mutedBy, isMuted := api.groupMutedFunc(alertGroup.RouteID, alertGroup.GroupKey) | |||
if !*params.Muted && isMuted { |
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 skips muted groups if muted
is false.
@@ -206,6 +206,8 @@ type AlertGroup struct { | |||
Alerts types.AlertSlice | |||
Labels model.LabelSet | |||
Receiver string | |||
GroupKey string | |||
RouteID string |
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.
Needed to add RouteID
here because we added it to the marker. Without it, we cannot see if a group is muted or not.
This commit updates /api/v2/alerts/groups to show if an alert is suppressed from one or more active or mute time intervals. While the muted by field can be found in /api/v2/alerts, it is not used here because /api/v2/alerts does not take aggregation or routing into consideration. It also updates the UI to support filtering muted alerts via the Muted checkbox. Signed-off-by: George Robinson <[email protected]>
7b804a1
to
6c2a305
Compare
@@ -117,7 +117,7 @@ func PostableSilenceToProto(s *open_api_models.PostableSilence) (*silencepb.Sile | |||
} | |||
|
|||
// AlertToOpenAPIAlert converts internal alerts, alert types, and receivers to *open_api_models.GettableAlert. | |||
func AlertToOpenAPIAlert(alert *types.Alert, status types.AlertStatus, receivers []string) *open_api_models.GettableAlert { | |||
func AlertToOpenAPIAlert(alert *types.Alert, status types.AlertStatus, receivers, mutedBy []string) *open_api_models.GettableAlert { |
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.
mutedBy
is separate from types.AlertStatus
because it is related to groups, and does not come from the AlertMarker
interface.
This commit updates
/api/v2/alerts/groups
to show if an alert is suppressed from one or more active or mute time intervals. While the muted by field can be found in/api/v2/alerts
, it is not used here because/api/v2/alerts
does not take aggregation or routing into consideration.It also updates the UI to support filtering muted alerts via the Muted checkbox.