diff --git a/api/api.go b/api/api.go index b9e2ef15..aae8da72 100644 --- a/api/api.go +++ b/api/api.go @@ -496,6 +496,8 @@ func (api *API) insertAlerts(w http.ResponseWriter, r *http.Request, alerts ...* validationErrs = &types.MultiError{} ) for _, a := range alerts { + removeEmptyLabels(a.Labels) + if err := a.Validate(); err != nil { validationErrs.Add(err) numInvalidAlerts.Inc() @@ -522,6 +524,14 @@ func (api *API) insertAlerts(w http.ResponseWriter, r *http.Request, alerts ...* api.respond(w, nil) } +func removeEmptyLabels(ls model.LabelSet) { + for k, v := range ls { + if string(v) == "" { + delete(ls, k) + } + } +} + func (api *API) setSilence(w http.ResponseWriter, r *http.Request) { var sil types.Silence if err := api.receive(r, &sil); err != nil {