mirror of
https://github.com/prometheus/alertmanager
synced 2025-02-17 19:17:07 +00:00
api: fix missing silence initialization
This commit is contained in:
parent
202235fb79
commit
1a93b01234
7
api.go
7
api.go
@ -283,14 +283,15 @@ func (api *API) insertAlerts(w http.ResponseWriter, r *http.Request, alerts ...*
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (api *API) addSilence(w http.ResponseWriter, r *http.Request) {
|
func (api *API) addSilence(w http.ResponseWriter, r *http.Request) {
|
||||||
var sil types.Silence
|
var msil model.Silence
|
||||||
if err := receive(r, &sil); err != nil {
|
if err := receive(r, &msil); err != nil {
|
||||||
respondError(w, apiError{
|
respondError(w, apiError{
|
||||||
typ: errorBadData,
|
typ: errorBadData,
|
||||||
err: err,
|
err: err,
|
||||||
}, nil)
|
}, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
sil := types.NewSilence(&msil)
|
||||||
|
|
||||||
if sil.CreatedAt.IsZero() {
|
if sil.CreatedAt.IsZero() {
|
||||||
sil.CreatedAt = time.Now()
|
sil.CreatedAt = time.Now()
|
||||||
@ -304,7 +305,7 @@ func (api *API) addSilence(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
sid, err := api.silences.Set(&sil)
|
sid, err := api.silences.Set(sil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
respondError(w, apiError{
|
respondError(w, apiError{
|
||||||
typ: errorInternal,
|
typ: errorInternal,
|
||||||
|
Loading…
Reference in New Issue
Block a user