(cherry picked from commit d2f3631a47)
Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
This commit is contained in:
co-authored by
Jean-Philippe Quéméner
parent
8d34a58a72
commit
b9621d08a5
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user