silence: Parse Alertmanager API response

This commit is contained in:
Thorben Günther 2023-02-12 16:07:49 +01:00
parent 81ff7bd90e
commit 38fa5f9f71
No known key found for this signature in database
GPG key ID: 415CD778D8C5AFED

View file

@ -32,6 +32,10 @@ type silenceBody struct {
Labels map[string]string `json:"labels"`
}
type silenceResponse struct {
ID string `json:"silenceID"`
}
func (rcv *receiver) handleSilences(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
@ -125,5 +129,11 @@ func (rcv *receiver) handleSilences(w http.ResponseWriter, r *http.Request) {
return
}
rcv.logger.Debugf("silences: created new silence %s", string(b))
var id silenceResponse
if err := json.Unmarshal(b, &id); err != nil {
rcv.logger.Debugf("silences: %v", err)
return
}
rcv.logger.Debugf("silences: created new silence %s", id.ID)
}