Documentation ¶
Index ¶
- func AllReceivers(route *config.Route) (res []string)
- func GrafanaToUpstreamConfig(cfg *PostableApiAlertingConfig) config.Config
- type Config
- type ObjectMatcherAPIModel
- type ObjectMatchers
- type ObjectMatchersAPIModel
- type PostableApiAlertingConfig
- func (c *PostableApiAlertingConfig) GetMuteTimeIntervals() []config.MuteTimeInterval
- func (c *PostableApiAlertingConfig) GetReceivers() []*PostableApiReceiver
- func (c *PostableApiAlertingConfig) GetRoute() *Route
- func (c *PostableApiAlertingConfig) GetTimeIntervals() []config.TimeInterval
- func (c *PostableApiAlertingConfig) ReceiverType() ReceiverType
- func (c *PostableApiAlertingConfig) UnmarshalJSON(b []byte) error
- func (c *PostableApiAlertingConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (c *PostableApiAlertingConfig) Validate() error
- type PostableApiReceiver
- type PostableGrafanaReceiver
- type PostableGrafanaReceivers
- type Provenance
- type RawMessage
- type ReceiverType
- type Route
- func (r *Route) AsAMRoute() *config.Route
- func (r *Route) ResourceID() string
- func (r *Route) ResourceType() string
- func (r *Route) UnmarshalYAML(unmarshal func(interface{}) error) error
- func (r *Route) Validate() error
- func (r *Route) ValidateChild() error
- func (r *Route) ValidateMuteTimes(timeIntervals map[string]struct{}) error
- func (r *Route) ValidateReceivers(receivers map[string]struct{}) error
- func (r *Route) ValidateTimeIntervals(timeIntervals map[string]struct{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllReceivers ¶
AllReceivers will recursively walk a routing tree and return a list of all the referenced receiver names.
func GrafanaToUpstreamConfig ¶
func GrafanaToUpstreamConfig(cfg *PostableApiAlertingConfig) config.Config
GrafanaToUpstreamConfig converts a Grafana alerting configuration into an upstream Alertmanager configuration. It ignores the configuration for Grafana receivers, adding only their names.
Types ¶
type Config ¶
type Config struct { Global *config.GlobalConfig `yaml:"global,omitempty" json:"global,omitempty"` Route *Route `yaml:"route,omitempty" json:"route,omitempty"` InhibitRules []config.InhibitRule `yaml:"inhibit_rules,omitempty" json:"inhibit_rules,omitempty"` // MuteTimeIntervals is deprecated and will be removed before Alertmanager 1.0. MuteTimeIntervals []config.MuteTimeInterval `yaml:"mute_time_intervals,omitempty" json:"mute_time_intervals,omitempty"` TimeIntervals []config.TimeInterval `yaml:"time_intervals,omitempty" json:"time_intervals,omitempty"` Templates []string `yaml:"templates,omitempty" json:"templates,omitempty"` }
Config is the top-level configuration for Alertmanager's config files.
func (*Config) UnmarshalJSON ¶
Config is the entrypoint for the embedded Alertmanager config with the exception of receivers. Prometheus historically uses yaml files as the method of configuration and thus some post-validation is included in the UnmarshalYAML method. Here we simply run this with a noop unmarshaling function in order to benefit from said validation.
func (*Config) UnmarshalYAML ¶
type ObjectMatcherAPIModel ¶
type ObjectMatcherAPIModel [3]string
ObjectMatcher is a matcher that can be used to filter alerts. swagger:model ObjectMatcher
type ObjectMatchers ¶
swagger:ignore ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects that have already been parsed.
func (ObjectMatchers) MarshalJSON ¶
func (m ObjectMatchers) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface for Matchers.
func (ObjectMatchers) MarshalYAML ¶
func (m ObjectMatchers) MarshalYAML() (interface{}, error)
MarshalYAML implements the yaml.Marshaler interface for Matchers.
func (*ObjectMatchers) UnmarshalJSON ¶
func (m *ObjectMatchers) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface for Matchers.
func (*ObjectMatchers) UnmarshalYAML ¶
func (m *ObjectMatchers) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML implements the yaml.Unmarshaler interface for Matchers.
type ObjectMatchersAPIModel ¶
type ObjectMatchersAPIModel []ObjectMatcherAPIModel
ObjectMatchers is a list of matchers that can be used to filter alerts. swagger:model ObjectMatchers
type PostableApiAlertingConfig ¶
type PostableApiAlertingConfig struct { Config `yaml:",inline"` // Override with our superset receiver type Receivers []*PostableApiReceiver `yaml:"receivers,omitempty" json:"receivers,omitempty"` }
nolint:revive
func Load ¶
func Load(rawCfg []byte) (*PostableApiAlertingConfig, error)
Load parses a slice of bytes (json/yaml) into a configuration and validates it.
func LoadCompat ¶
func LoadCompat(rawCfg []byte) (*PostableApiAlertingConfig, error)
LoadCompat loads a PostableApiAlertingConfig from a YAML configuration and runs validations to ensure that it works with the Mimir Alertmanager.
func (*PostableApiAlertingConfig) GetMuteTimeIntervals ¶
func (c *PostableApiAlertingConfig) GetMuteTimeIntervals() []config.MuteTimeInterval
func (*PostableApiAlertingConfig) GetReceivers ¶
func (c *PostableApiAlertingConfig) GetReceivers() []*PostableApiReceiver
func (*PostableApiAlertingConfig) GetRoute ¶
func (c *PostableApiAlertingConfig) GetRoute() *Route
func (*PostableApiAlertingConfig) GetTimeIntervals ¶
func (c *PostableApiAlertingConfig) GetTimeIntervals() []config.TimeInterval
func (*PostableApiAlertingConfig) ReceiverType ¶
func (c *PostableApiAlertingConfig) ReceiverType() ReceiverType
Type requires validate has been called and just checks the first receiver type
func (*PostableApiAlertingConfig) UnmarshalJSON ¶
func (c *PostableApiAlertingConfig) UnmarshalJSON(b []byte) error
func (*PostableApiAlertingConfig) UnmarshalYAML ¶
func (c *PostableApiAlertingConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
func (*PostableApiAlertingConfig) Validate ¶
func (c *PostableApiAlertingConfig) Validate() error
Validate ensures that the two routing trees use the correct receiver types.
type PostableApiReceiver ¶
type PostableApiReceiver struct { config.Receiver `yaml:",inline"` PostableGrafanaReceivers `yaml:",inline"` }
nolint:revive
func (*PostableApiReceiver) GetName ¶
func (r *PostableApiReceiver) GetName() string
func (*PostableApiReceiver) Type ¶
func (r *PostableApiReceiver) Type() ReceiverType
func (*PostableApiReceiver) UnmarshalJSON ¶
func (r *PostableApiReceiver) UnmarshalJSON(b []byte) error
func (*PostableApiReceiver) UnmarshalYAML ¶
func (r *PostableApiReceiver) UnmarshalYAML(unmarshal func(interface{}) error) error
type PostableGrafanaReceiver ¶
type PostableGrafanaReceiver struct { UID string `json:"uid" yaml:"uid"` Name string `json:"name" yaml:"name"` Type string `json:"type" yaml:"type"` DisableResolveMessage bool `json:"disableResolveMessage" yaml:"disableResolveMessage"` Settings RawMessage `json:"settings,omitempty" yaml:"settings,omitempty"` SecureSettings map[string]string `json:"secureSettings,omitempty" yaml:"secureSettings,omitempty"` }
func (*PostableGrafanaReceiver) DecryptSecureSettings ¶
func (pgr *PostableGrafanaReceiver) DecryptSecureSettings(decryptFn func(payload []byte) ([]byte, error)) (map[string]string, error)
DecryptSecureSettings returns a map containing the decoded and decrypted secure settings.
type PostableGrafanaReceivers ¶
type PostableGrafanaReceivers struct {
GrafanaManagedReceivers []*PostableGrafanaReceiver `yaml:"grafana_managed_receiver_configs,omitempty" json:"grafana_managed_receiver_configs,omitempty"`
}
type Provenance ¶
type Provenance string
type RawMessage ¶
type RawMessage json.RawMessage // This type alias adds YAML marshaling to the json.RawMessage.
func (RawMessage) MarshalJSON ¶
func (r RawMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns m as the JSON encoding of m.
func (RawMessage) MarshalYAML ¶
func (r RawMessage) MarshalYAML() (interface{}, error)
func (*RawMessage) UnmarshalJSON ¶
func (r *RawMessage) UnmarshalJSON(data []byte) error
func (*RawMessage) UnmarshalYAML ¶
func (r *RawMessage) UnmarshalYAML(unmarshal func(interface{}) error) error
type ReceiverType ¶
type ReceiverType int
const ( GrafanaReceiverType ReceiverType = 1 << iota AlertmanagerReceiverType EmptyReceiverType = GrafanaReceiverType | AlertmanagerReceiverType )
func (ReceiverType) Can ¶
func (r ReceiverType) Can(other ReceiverType) bool
Can determines whether a receiver type can implement another receiver type. This is useful as receivers with just names but no contact points are valid in all backends.
func (ReceiverType) String ¶
func (r ReceiverType) String() string
type Route ¶
type Route struct { Receiver string `yaml:"receiver,omitempty" json:"receiver,omitempty"` GroupByStr []string `yaml:"group_by,omitempty" json:"group_by,omitempty"` GroupBy []model.LabelName `yaml:"-" json:"-"` GroupByAll bool `yaml:"-" json:"-"` // Deprecated. Remove before v1.0 release. Match map[string]string `yaml:"match,omitempty" json:"match,omitempty"` // Deprecated. Remove before v1.0 release. MatchRE config.MatchRegexps `yaml:"match_re,omitempty" json:"match_re,omitempty"` Matchers config.Matchers `yaml:"matchers,omitempty" json:"matchers,omitempty"` ObjectMatchers ObjectMatchers `yaml:"object_matchers,omitempty" json:"object_matchers,omitempty"` MuteTimeIntervals []string `yaml:"mute_time_intervals,omitempty" json:"mute_time_intervals,omitempty"` ActiveTimeIntervals []string `yaml:"active_time_intervals,omitempty" json:"active_time_intervals,omitempty"` Continue bool `yaml:"continue" json:"continue,omitempty"` Routes []*Route `yaml:"routes,omitempty" json:"routes,omitempty"` GroupWait *model.Duration `yaml:"group_wait,omitempty" json:"group_wait,omitempty"` GroupInterval *model.Duration `yaml:"group_interval,omitempty" json:"group_interval,omitempty"` RepeatInterval *model.Duration `yaml:"repeat_interval,omitempty" json:"repeat_interval,omitempty"` Provenance Provenance `yaml:"provenance,omitempty" json:"provenance,omitempty"` }
A Route is a node that contains definitions of how to handle alerts. This is modified from the upstream alertmanager in that it adds the ObjectMatchers property.
func AsGrafanaRoute ¶
AsGrafanaRoute returns a Grafana route from an Alertmanager route.
func (*Route) AsAMRoute ¶
AsAMRoute returns an Alertmanager route from a Grafana route. The ObjectMatchers are converted to Matchers.
func (*Route) ResourceID ¶
func (*Route) ResourceType ¶
func (*Route) UnmarshalYAML ¶
UnmarshalYAML implements the yaml.Unmarshaler interface for Route. This is a copy of alertmanager's upstream except it removes validation on the label key.
func (*Route) Validate ¶
Validate normalizes a Route r, and returns errors if r is an invalid root route. Root routes must satisfy a few additional conditions.
func (*Route) ValidateChild ¶
ValidateChild normalizes a possibly nested Route r, and returns errors if r is invalid.
func (*Route) ValidateMuteTimes ¶
ValidateMuteTimes validates that all mute time intervals referenced by the route exist. TODO: Can be removed once grafana/grafan uses ValidateTimeIntervals instead.
func (*Route) ValidateReceivers ¶
func (*Route) ValidateTimeIntervals ¶
ValidateTimeIntervals checks that all time intervals referenced by the route exist in the provided map.