definition

package
v0.0.0-...-bb4f4f4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: AGPL-3.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllReceivers

func AllReceivers(route *config.Route) (res []string)

AllReceivers will recursively walk a routing tree and return a list of all the referenced receiver 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" json:"templates"`
}

Config is the top-level configuration for Alertmanager's config files.

func (*Config) UnmarshalJSON

func (c *Config) UnmarshalJSON(b []byte) error

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.

type ObjectMatcherAPIModel

type ObjectMatcherAPIModel [3]string

ObjectMatcher is a matcher that can be used to filter alerts. swagger:model ObjectMatcher

type ObjectMatchers

type ObjectMatchers labels.Matchers

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 (*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) 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 (*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"`
	Name                  string            `json:"name"`
	Type                  string            `json:"type"`
	DisableResolveMessage bool              `json:"disableResolveMessage"`
	Settings              RawMessage        `json:"settings,omitempty"`
	SecureSettings        map[string]string `json:"secureSettings"`
}

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"`
	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

func AsGrafanaRoute(r *config.Route) *Route

AsGrafanaRoute returns a Grafana route from an Alertmanager route.

func (*Route) AsAMRoute

func (r *Route) AsAMRoute() *config.Route

AsAMRoute returns an Alertmanager route from a Grafana route. The ObjectMatchers are converted to Matchers.

func (*Route) ResourceID

func (r *Route) ResourceID() string

func (*Route) ResourceType

func (r *Route) ResourceType() string

func (*Route) UnmarshalYAML

func (r *Route) UnmarshalYAML(unmarshal func(interface{}) error) error

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

func (r *Route) Validate() error

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

func (r *Route) ValidateChild() error

ValidateChild normalizes a possibly nested Route r, and returns errors if r is invalid.

func (*Route) ValidateMuteTimes

func (r *Route) ValidateMuteTimes(muteTimes map[string]struct{}) error

func (*Route) ValidateReceivers

func (r *Route) ValidateReceivers(receivers map[string]struct{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL