Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Alerting: Implement /status for the notification system
Implements the necessary plumbing to have a /status endpoint on the notification system.
- Loading branch information
Showing
10 changed files
with
242 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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) | ||
} |
Oops, something went wrong.