-
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
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
This commit updates /api/v2/alerts/groups to show if an alert is suppressed from one or more active or mute time intervals. It does not update the /api/v2/alerts API because that API 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 <george.robinson@grafana.com>
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.
extendedGettableAlert: | ||
allOf: | ||
- type: object | ||
properties: |
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've had to duplicate all of these properties due to a bug in swagger generation for Elm that occurs when using inheritance.
@@ -505,6 +542,29 @@ definitions: | |||
- state | |||
- silencedBy | |||
- inhibitedBy | |||
extendedAlertStatus: | |||
type: object | |||
properties: |
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've also had to duplicate this otherwise the state
enum does not get inherited and the Elm code fails.
@@ -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.
Signed-off-by: George Robinson <george.robinson@grafana.com>
This commit updates the Alert Groups API (
/api/v2/alerts/groups
) to show if an alert is suppressed from one or more active or mute time intervals. It does not update the Alerts API (/api/v2/alerts
) because that API does not take aggregation or routing into consideration.Based on #3793.