Alerting: Fetch all applied alerting configurations (#65728)

* WIP

* skip invalid historic configurations instead of erroring

* add warning log when bad historic config is found

* remove unused custom marshaller for GettableHistoricUserConfig

* add id to historic user config, move limit check to store, fix typo

* swagger spec
This commit is contained in:
Santiago
2023-03-31 17:43:04 -03:00
committed by GitHub
parent 412fc4dcfb
commit aba91d3053
17 changed files with 920 additions and 117 deletions
@@ -54,6 +54,13 @@ import (
// 400: ValidationError
// 404: NotFound
// swagger:route GET /api/alertmanager/grafana/config/history alertmanager RouteGetGrafanaAlertingConfigHistory
//
// gets Alerting configurations that were successfully applied in the past
//
// Responses:
// 200: GettableHistoricUserConfigs
// swagger:route DELETE /api/alertmanager/grafana/config/api/v1/alerts alertmanager RouteDeleteGrafanaAlertingConfig
//
// deletes the Alerting config for a tenant
@@ -229,6 +236,13 @@ type AlertManagerNotReady struct{}
// swagger:model
type MultiStatus struct{}
// swagger:parameters RouteGetGrafanaAlertingConfigHistory
type RouteGetGrafanaAlertingConfigHistoryParams struct {
// Limit response to n historic configurations.
// in:query
Limit int `json:"limit"`
}
// swagger:parameters RoutePostTestGrafanaReceivers
type TestReceiversConfigParams struct {
// in:body
@@ -633,6 +647,20 @@ func (c *GettableUserConfig) GetGrafanaReceiverMap() map[string]*GettableGrafana
return UIDs
}
type GettableHistoricUserConfig struct {
ID int64 `yaml:"id" json:"id"`
TemplateFiles map[string]string `yaml:"template_files" json:"template_files"`
TemplateFileProvenances map[string]Provenance `yaml:"template_file_provenances,omitempty" json:"template_file_provenances,omitempty"`
AlertmanagerConfig GettableApiAlertingConfig `yaml:"alertmanager_config" json:"alertmanager_config"`
LastApplied *strfmt.DateTime `yaml:"last_applied,omitempty" json:"last_applied,omitempty"`
}
// swagger:response GettableHistoricUserConfigs
type GettableHistoricUserConfigs struct {
// in:body
Body []GettableHistoricUserConfig
}
type GettableApiAlertingConfig struct {
Config `yaml:",inline"`
MuteTimeProvenances map[string]Provenance `yaml:"muteTimeProvenances,omitempty" json:"muteTimeProvenances,omitempty"`