mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* Alerting: Implement /status for the notification system Implements the necessary plumbing to have a /status endpoint on the notification system. * Add API examples * Update API specs * Update prometheus/common dependency Co-authored-by: Sofia Papagiannaki <sofia@grafana.com>
23 lines
622 B
Go
23 lines
622 B
Go
package notifier
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
apimodels "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
|
|
)
|
|
|
|
func (am *Alertmanager) GetStatus() apimodels.GettableStatus {
|
|
am.reloadConfigMtx.RLock()
|
|
defer am.reloadConfigMtx.RUnlock()
|
|
|
|
var amConfig apimodels.PostableApiAlertingConfig
|
|
if am.config != nil {
|
|
err := json.Unmarshal(am.config, &amConfig)
|
|
if err != nil {
|
|
// this should never error here, if the configuration is running it should be valid.
|
|
am.logger.Error("unable to marshal alertmanager configuration", "err", err)
|
|
}
|
|
}
|
|
return *apimodels.NewGettableStatus(&amConfig)
|
|
}
|