silence: Parse Alertmanager API response
This commit is contained in:
parent
81ff7bd90e
commit
38fa5f9f71
1 changed files with 11 additions and 1 deletions
12
silence.go
12
silence.go
|
@ -32,6 +32,10 @@ type silenceBody struct {
|
||||||
Labels map[string]string `json:"labels"`
|
Labels map[string]string `json:"labels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type silenceResponse struct {
|
||||||
|
ID string `json:"silenceID"`
|
||||||
|
}
|
||||||
|
|
||||||
func (rcv *receiver) handleSilences(w http.ResponseWriter, r *http.Request) {
|
func (rcv *receiver) handleSilences(w http.ResponseWriter, r *http.Request) {
|
||||||
defer r.Body.Close()
|
defer r.Body.Close()
|
||||||
|
|
||||||
|
@ -125,5 +129,11 @@ func (rcv *receiver) handleSilences(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue