mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: add mute timings provenance to config api (#50149)
This commit is contained in:
parent
5f1305d280
commit
d2f3631a47
@ -627,8 +627,8 @@ func (c *GettableUserConfig) GetGrafanaReceiverMap() map[string]*GettableGrafana
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GettableApiAlertingConfig struct {
|
type GettableApiAlertingConfig struct {
|
||||||
Config `yaml:",inline"`
|
Config `yaml:",inline"`
|
||||||
|
MuteTimeProvenances map[string]models.Provenance `yaml:"muteTimeProvenances,omitempty" json:"muteTimeProvenances,omitempty"`
|
||||||
// Override with our superset receiver type
|
// Override with our superset receiver type
|
||||||
Receivers []*GettableApiReceiver `yaml:"receivers,omitempty" json:"receivers,omitempty"`
|
Receivers []*GettableApiReceiver `yaml:"receivers,omitempty" json:"receivers,omitempty"`
|
||||||
}
|
}
|
||||||
@ -851,20 +851,6 @@ func checkTimeInterval(r *Route, timeIntervals map[string]struct{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// swagger:model
|
|
||||||
type MuteTimeInterval struct {
|
|
||||||
config.MuteTimeInterval
|
|
||||||
Provenance models.Provenance `json:"provenance,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *MuteTimeInterval) ResourceType() string {
|
|
||||||
return "muteTimeInterval"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mt *MuteTimeInterval) ResourceID() string {
|
|
||||||
return mt.MuteTimeInterval.Name
|
|
||||||
}
|
|
||||||
|
|
||||||
type PostableApiAlertingConfig struct {
|
type PostableApiAlertingConfig struct {
|
||||||
Config `yaml:",inline"`
|
Config `yaml:",inline"`
|
||||||
|
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package definitions
|
package definitions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/grafana/grafana/pkg/services/ngalert/models"
|
||||||
|
"github.com/prometheus/alertmanager/config"
|
||||||
|
)
|
||||||
|
|
||||||
// swagger:route GET /api/v1/provisioning/mute-timings provisioning RouteGetMuteTimings
|
// swagger:route GET /api/v1/provisioning/mute-timings provisioning RouteGetMuteTimings
|
||||||
//
|
//
|
||||||
// Get all the mute timings.
|
// Get all the mute timings.
|
||||||
@ -62,3 +67,17 @@ type MuteTimingPayload struct {
|
|||||||
// in:body
|
// in:body
|
||||||
Body MuteTimeInterval
|
Body MuteTimeInterval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// swagger:model
|
||||||
|
type MuteTimeInterval struct {
|
||||||
|
config.MuteTimeInterval
|
||||||
|
Provenance models.Provenance `json:"provenance,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *MuteTimeInterval) ResourceType() string {
|
||||||
|
return "muteTimeInterval"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mt *MuteTimeInterval) ResourceID() string {
|
||||||
|
return mt.MuteTimeInterval.Name
|
||||||
|
}
|
||||||
|
@ -155,5 +155,12 @@ func (moa *MultiOrgAlertmanager) mergeProvenance(ctx context.Context, config def
|
|||||||
}
|
}
|
||||||
config.TemplateFileProvenances = tmplProvs
|
config.TemplateFileProvenances = tmplProvs
|
||||||
|
|
||||||
|
mt := definitions.MuteTimeInterval{}
|
||||||
|
mtProvs, err := moa.ProvStore.GetProvenances(ctx, org, mt.ResourceType())
|
||||||
|
if err != nil {
|
||||||
|
return definitions.GettableUserConfig{}, nil
|
||||||
|
}
|
||||||
|
config.AlertmanagerConfig.MuteTimeProvenances = mtProvs
|
||||||
|
|
||||||
return config, nil
|
return config, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user