Skip to content
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

also hide inhibited alerts #1039

Merged
merged 2 commits into from
Oct 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ func (api *API) listAlerts(w http.ResponseWriter, r *http.Request) {
re *regexp.Regexp
// Initialize result slice to prevent api returning `null` when there
// are no alerts present
res = []*dispatch.APIAlert{}
matchers = []*labels.Matcher{}
showSilenced = true
res = []*dispatch.APIAlert{}
matchers = []*labels.Matcher{}
showSilenced = true
showInhibited = true
)

if filter := r.FormValue("filter"); filter != "" {
Expand Down Expand Up @@ -295,6 +296,21 @@ func (api *API) listAlerts(w http.ResponseWriter, r *http.Request) {
}
}

if inhibitedParam := r.FormValue("inhibited"); inhibitedParam != "" {
if inhibitedParam == "false" {
showInhibited = false
} else if inhibitedParam != "true" {
respondError(w, apiError{
typ: errorBadData,
err: fmt.Errorf(
"parameter 'inhibited' can either be 'true' or 'false', not '%v'",
inhibitedParam,
),
}, nil)
return
}
}

if receiverParam := r.FormValue("receiver"); receiverParam != "" {
re, err = regexp.Compile("^(?:" + receiverParam + ")$")
if err != nil {
Expand Down Expand Up @@ -343,6 +359,10 @@ func (api *API) listAlerts(w http.ResponseWriter, r *http.Request) {
continue
}

if !showInhibited && len(status.InhibitedBy) != 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still hoping that we'll one day have a real index around this 🙂

continue
}

apiAlert := &dispatch.APIAlert{
Alert: &a.Alert,
Status: status,
Expand Down