amconfig

package
v0.0.0-...-122797d Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultWebhookConfig defines default values for Webhook configurations.
	DefaultWebhookConfig = WebhookConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
	}

	// DefaultWebexConfig defines default values for Webex configurations.
	DefaultWebexConfig = WebexConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		Message: `{{ template "webex.default.message" . }}`,
	}

	// DefaultDiscordConfig defines default values for Discord configurations.
	DefaultDiscordConfig = DiscordConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		Title:   `{{ template "discord.default.title" . }}`,
		Message: `{{ template "discord.default.message" . }}`,
	}

	// DefaultEmailConfig defines default values for Email configurations.
	DefaultEmailConfig = EmailConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: false,
		},
		HTML: `{{ template "email.default.html" . }}`,
		Text: ``,
	}

	// DefaultEmailSubject defines the default Subject header of an Email.
	DefaultEmailSubject = `{{ template "email.default.subject" . }}`

	// DefaultPagerdutyDetails defines the default values for PagerDuty details.
	DefaultPagerdutyDetails = map[string]string{
		"firing":       `{{ template "pagerduty.default.instances" .Alerts.Firing }}`,
		"resolved":     `{{ template "pagerduty.default.instances" .Alerts.Resolved }}`,
		"num_firing":   `{{ .Alerts.Firing | len }}`,
		"num_resolved": `{{ .Alerts.Resolved | len }}`,
	}

	// DefaultPagerdutyConfig defines default values for PagerDuty configurations.
	DefaultPagerdutyConfig = PagerdutyConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		Description: `{{ template "pagerduty.default.description" .}}`,
		Client:      `{{ template "pagerduty.default.client" . }}`,
		ClientURL:   `{{ template "pagerduty.default.clientURL" . }}`,
	}

	// DefaultSlackConfig defines default values for Slack configurations.
	DefaultSlackConfig = SlackConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: false,
		},
		Color:      `{{ if eq .Status "firing" }}danger{{ else }}good{{ end }}`,
		Username:   `{{ template "slack.default.username" . }}`,
		Title:      `{{ template "slack.default.title" . }}`,
		TitleLink:  `{{ template "slack.default.titlelink" . }}`,
		IconEmoji:  `{{ template "slack.default.iconemoji" . }}`,
		IconURL:    `{{ template "slack.default.iconurl" . }}`,
		Pretext:    `{{ template "slack.default.pretext" . }}`,
		Text:       `{{ template "slack.default.text" . }}`,
		Fallback:   `{{ template "slack.default.fallback" . }}`,
		CallbackID: `{{ template "slack.default.callbackid" . }}`,
		Footer:     `{{ template "slack.default.footer" . }}`,
	}

	// DefaultOpsGenieConfig defines default values for OpsGenie configurations.
	DefaultOpsGenieConfig = OpsGenieConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		Message:     `{{ template "opsgenie.default.message" . }}`,
		Description: `{{ template "opsgenie.default.description" . }}`,
		Source:      `{{ template "opsgenie.default.source" . }}`,
	}

	// DefaultWechatConfig defines default values for wechat configurations.
	DefaultWechatConfig = WechatConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		Message: `{{ template "wechat.default.message" . }}`,
		ToUser:  `{{ template "wechat.default.to_user" . }}`,
		ToParty: `{{ template "wechat.default.to_party" . }}`,
		ToTag:   `{{ template "wechat.default.to_tag" . }}`,
		AgentID: `{{ template "wechat.default.agent_id" . }}`,
	}

	// DefaultVictorOpsConfig defines default values for VictorOps configurations.
	DefaultVictorOpsConfig = VictorOpsConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		MessageType:       `CRITICAL`,
		StateMessage:      `{{ template "victorops.default.state_message" . }}`,
		EntityDisplayName: `{{ template "victorops.default.entity_display_name" . }}`,
		MonitoringTool:    `{{ template "victorops.default.monitoring_tool" . }}`,
	}

	// DefaultPushoverConfig defines default values for Pushover configurations.
	DefaultPushoverConfig = PushoverConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		Title:    `{{ template "pushover.default.title" . }}`,
		Message:  `{{ template "pushover.default.message" . }}`,
		URL:      `{{ template "pushover.default.url" . }}`,
		Priority: `{{ if eq .Status "firing" }}2{{ else }}0{{ end }}`,
		Retry:    duration(1 * time.Minute),
		Expire:   duration(1 * time.Hour),
		HTML:     false,
	}

	// DefaultSNSConfig defines default values for SNS configurations.
	DefaultSNSConfig = SNSConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		Subject: `{{ template "sns.default.subject" . }}`,
		Message: `{{ template "sns.default.message" . }}`,
	}

	DefaultTelegramConfig = TelegramConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		DisableNotifications: false,
		Message:              `{{ template "telegram.default.message" . }}`,
		ParseMode:            "HTML",
	}

	DefaultMSTeamsConfig = MSTeamsConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: true,
		},
		Title:   `{{ template "msteams.default.title" . }}`,
		Summary: `{{ template "msteams.default.summary" . }}`,
		Text:    `{{ template "msteams.default.text" . }}`,
	}
)

Functions

func HasEmailOrWebhookConfig

func HasEmailOrWebhookConfig(r Receiver) bool

Types

type Config

type Config struct {
	Global       *GlobalConfig `yaml:"global,omitempty" json:"global,omitempty"`
	Route        *Route        `yaml:"route,omitempty" json:"route,omitempty"`
	InhibitRules []InhibitRule `yaml:"inhibit_rules,omitempty" json:"inhibitRules,omitempty"`
	Receivers    []Receiver    `yaml:"receivers,omitempty" json:"receivers,omitempty"`
	Templates    []string      `yaml:"templates" json:"templates"`
	// Deprecated. Remove before v1.0 release.
	MuteTimeIntervals []MuteTimeInterval `yaml:"mute_time_intervals,omitempty" json:"muteTimeIntervals,omitempty"`
	TimeIntervals     []TimeInterval     `yaml:"time_intervals,omitempty" json:"timeTntervals,omitempty"`
	// contains filtered or unexported fields
}

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

func Load

func Load(s string) (*Config, error)

Load parses the YAML input s into a Config.

func LoadFile

func LoadFile(filename string) (*Config, error)

LoadFile parses the given YAML file into a Config.

func (Config) String

func (c Config) String() string

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for Config.

type DingTalkConfig

type DingTalkConfig struct {
	ConfigFile string `json:"-" gorm:"column:config_file;type:varchar(50)"`
	AlertName  string `json:"-" gorm:"column:alert_name;type:varchar(50)"`
	UUID       string `json:"-" gorm:"column:uuid;unique;type:varchar(50)"`
	URL        string `json:"url,omitempty" gorm:"column:url;type:varchar(150)"`
	Secret     string `json:"secret,omitempty" gorm:"secret"`
}

func (DingTalkConfig) TableName

func (t DingTalkConfig) TableName() string

type DiscordConfig

type DiscordConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig     *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`
	WebhookURL     *URL                         `yaml:"webhook_url,omitempty" json:"webhookUrl,omitempty"`
	WebhookURLFile string                       `yaml:"webhook_url_file,omitempty" json:"webhookUrlFile,omitempty"`

	Title   string `yaml:"title,omitempty" json:"title,omitempty"`
	Message string `yaml:"message,omitempty" json:"message,omitempty"`
}

DiscordConfig configures notifications via Discord.

func (*DiscordConfig) UnmarshalYAML

func (c *DiscordConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type EmailConfig

type EmailConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	// Email address to notify.
	To               string               `yaml:"to,omitempty" json:"to,omitempty"`
	From             string               `yaml:"from,omitempty" json:"from,omitempty"`
	Hello            string               `yaml:"hello,omitempty" json:"hello,omitempty"`
	Smarthost        HostPort             `yaml:"smarthost,omitempty" json:"smarthost,omitempty"`
	AuthUsername     string               `yaml:"auth_username,omitempty" json:"authUsername,omitempty"`
	AuthPassword     Secret               `yaml:"auth_password,omitempty" json:"authPassword,omitempty"`
	AuthPasswordFile string               `yaml:"auth_password_file,omitempty" json:"authPasswordFile,omitempty"`
	AuthSecret       Secret               `yaml:"auth_secret,omitempty" json:"authSecret,omitempty"`
	AuthIdentity     string               `yaml:"auth_identity,omitempty" json:"authIdentity,omitempty"`
	Headers          map[string]string    `yaml:"headers,omitempty" json:"headers,omitempty"`
	HTML             string               `yaml:"html,omitempty" json:"html,omitempty"`
	Text             string               `yaml:"text,omitempty" json:"text,omitempty"`
	RequireTLS       *bool                `yaml:"require_tls,omitempty" json:"requireTls,omitempty"`
	TLSConfig        httpconfig.TLSConfig `yaml:"tls_config,omitempty" json:"tlsConfig,omitempty"`
}

EmailConfig configures notifications via mail.

func (*EmailConfig) UnmarshalJSON

func (c *EmailConfig) UnmarshalJSON(data []byte) error

func (*EmailConfig) UnmarshalYAML

func (c *EmailConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type GlobalConfig

type GlobalConfig struct {
	// ResolveTimeout is the time after which an alert is declared resolved
	// if it has not been updated.
	ResolveTimeout model.Duration `yaml:"resolve_timeout" json:"resolveTimeout"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	SMTPFrom             string   `yaml:"smtp_from,omitempty" json:"smtpFrom,omitempty"`
	SMTPHello            string   `yaml:"smtp_hello,omitempty" json:"smtpHello,omitempty"`
	SMTPSmarthost        HostPort `yaml:"smtp_smarthost,omitempty" json:"smtpSmarthost,omitempty"`
	SMTPAuthUsername     string   `yaml:"smtp_auth_username,omitempty" json:"smtpAuthUsername,omitempty"`
	SMTPAuthPassword     Secret   `yaml:"smtp_auth_password,omitempty" json:"smtpAuthPassword,omitempty"`
	SMTPAuthPasswordFile string   `yaml:"smtp_auth_password_file,omitempty" json:"smtpAuthPassword_file,omitempty"`
	SMTPAuthSecret       Secret   `yaml:"smtp_auth_secret,omitempty" json:"smtpAuthSecret,omitempty"`
	SMTPAuthIdentity     string   `yaml:"smtp_auth_identity,omitempty" json:"smtpAuthIdentity,omitempty"`
	SMTPRequireTLS       bool     `yaml:"smtp_require_tls" json:"smtpRequireTls,omitempty"`
	SlackAPIURL          *URL     `yaml:"slack_api_url,omitempty" json:"slackApiUrl,omitempty"`
	SlackAPIURLFile      string   `yaml:"slack_api_url_file,omitempty" json:"slackApiUrlFile,omitempty"`
	PagerdutyURL         *URL     `yaml:"pagerduty_url,omitempty" json:"pagerdutyUrl,omitempty"`
	OpsGenieAPIURL       *URL     `yaml:"opsgenie_api_url,omitempty" json:"opsgenieApiUrl,omitempty"`
	OpsGenieAPIKey       Secret   `yaml:"opsgenie_api_key,omitempty" json:"opsgenieApiKey,omitempty"`
	OpsGenieAPIKeyFile   string   `yaml:"opsgenie_api_key_file,omitempty" json:"opsgenieApiKeyFile,omitempty"`
	WeChatAPIURL         *URL     `yaml:"wechat_api_url,omitempty" json:"wechatApiUrl,omitempty"`
	WeChatAPISecret      Secret   `yaml:"wechat_api_secret,omitempty" json:"wechatApiSecret,omitempty"`
	WeChatAPICorpID      string   `yaml:"wechat_api_corp_id,omitempty" json:"wechatApiCorpId,omitempty"`
	VictorOpsAPIURL      *URL     `yaml:"victorops_api_url,omitempty" json:"victoropsApiUrl,omitempty"`
	VictorOpsAPIKey      Secret   `yaml:"victorops_api_key,omitempty" json:"victoropsApiKey,omitempty"`
	VictorOpsAPIKeyFile  string   `yaml:"victorops_api_key_file,omitempty" json:"victoropsApiKeyFile,omitempty"`
	TelegramAPIUrl       *URL     `yaml:"telegram_api_url,omitempty" json:"telegramApiUrl,omitempty"`
	WebexAPIURL          *URL     `yaml:"webex_api_url,omitempty" json:"webexApiUrl,omitempty"`
}

GlobalConfig defines configuration parameters that are valid globally unless overwritten.

func DefaultGlobalConfig

func DefaultGlobalConfig() GlobalConfig

DefaultGlobalConfig returns GlobalConfig with default values.

func (*GlobalConfig) UnmarshalYAML

func (c *GlobalConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for GlobalConfig.

type HostPort

type HostPort struct {
	Host string
	Port string
}

HostPort represents a "host:port" network address.

func (HostPort) MarshalJSON

func (hp HostPort) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for HostPort.

func (HostPort) MarshalYAML

func (hp HostPort) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for HostPort.

func (HostPort) String

func (hp HostPort) String() string

func (*HostPort) UnmarshalJSON

func (hp *HostPort) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for HostPort.

func (*HostPort) UnmarshalYAML

func (hp *HostPort) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for HostPort.

type InhibitRule

type InhibitRule struct {
	// SourceMatch defines a set of labels that have to equal the given
	// value for source alerts. Deprecated. Remove before v1.0 release.
	SourceMatch map[string]string `yaml:"source_match,omitempty" json:"sourceMatch,omitempty"`
	// SourceMatchRE defines pairs like SourceMatch but does regular expression
	// matching. Deprecated. Remove before v1.0 release.
	SourceMatchRE MatchRegexps `yaml:"source_match_re,omitempty" json:"sourceMatchRe,omitempty"`
	// SourceMatchers defines a set of label matchers that have to be fulfilled for source alerts.
	SourceMatchers Matchers `yaml:"source_matchers,omitempty" json:"sourceMatchers,omitempty"`
	// TargetMatch defines a set of labels that have to equal the given
	// value for target alerts. Deprecated. Remove before v1.0 release.
	TargetMatch map[string]string `yaml:"target_match,omitempty" json:"targetMatch,omitempty"`
	// TargetMatchRE defines pairs like TargetMatch but does regular expression
	// matching. Deprecated. Remove before v1.0 release.
	TargetMatchRE MatchRegexps `yaml:"target_match_re,omitempty" json:"targetMatchRe,omitempty"`
	// TargetMatchers defines a set of label matchers that have to be fulfilled for target alerts.
	TargetMatchers Matchers `yaml:"target_matchers,omitempty" json:"targetMatchers,omitempty"`
	// A set of labels that must be equal between the source and target alert
	// for them to be a match.
	Equal model.LabelNames `yaml:"equal,omitempty" json:"equal,omitempty"`
}

InhibitRule defines an inhibition rule that mutes alerts that match the target labels if an alert matching the source labels exists. Both alerts have to have a set of labels being equal.

func (*InhibitRule) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface for InhibitRule.

type MSTeamsConfig

type MSTeamsConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`
	HTTPConfig     *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`
	WebhookURL     *URL                         `yaml:"webhook_url,omitempty" json:"webhookUrl,omitempty"`
	WebhookURLFile string                       `yaml:"webhook_url_file,omitempty" json:"webhookUrlFile,omitempty"`

	Title   string `yaml:"title,omitempty" json:"title,omitempty"`
	Summary string `yaml:"summary,omitempty" json:"summary,omitempty"`
	Text    string `yaml:"text,omitempty" json:"text,omitempty"`
}

func (*MSTeamsConfig) UnmarshalYAML

func (c *MSTeamsConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

type MatchRegexps

type MatchRegexps map[string]Regexp

MatchRegexps represents a map of Regexp.

func (*MatchRegexps) UnmarshalYAML

func (m *MatchRegexps) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for MatchRegexps.

type Matchers

type Matchers labels.Matchers

Matchers is label.Matchers with an added UnmarshalYAML method to implement the yaml.Unmarshaler interface and MarshalYAML to implement the yaml.Marshaler interface.

func (Matchers) MarshalJSON

func (m Matchers) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Matchers.

func (Matchers) MarshalYAML

func (m Matchers) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for Matchers.

func (*Matchers) UnmarshalJSON

func (m *Matchers) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Matchers.

func (*Matchers) UnmarshalYAML

func (m *Matchers) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for Matchers.

type MuteTimeInterval

type MuteTimeInterval struct {
	Name          string                      `yaml:"name" json:"name"`
	TimeIntervals []timeinterval.TimeInterval `yaml:"time_intervals" json:"timeIntervals"`
}

MuteTimeInterval represents a named set of time intervals for which a route should be muted.

func (*MuteTimeInterval) UnmarshalYAML

func (mt *MuteTimeInterval) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for MuteTimeInterval.

type NotifierConfig

type NotifierConfig struct {
	VSendResolved bool `yaml:"send_resolved" json:"sendResolved"`
}

NotifierConfig contains base options common across all notifier configurations.

func (*NotifierConfig) SendResolved

func (nc *NotifierConfig) SendResolved() bool

type OpsGenieConfig

type OpsGenieConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	APIKey       Secret                    `yaml:"api_key,omitempty" json:"apiKey,omitempty"`
	APIKeyFile   string                    `yaml:"api_key_file,omitempty" json:"apiKeyFile,omitempty"`
	APIURL       *URL                      `yaml:"api_url,omitempty" json:"apiUrl,omitempty"`
	Message      string                    `yaml:"message,omitempty" json:"message,omitempty"`
	Description  string                    `yaml:"description,omitempty" json:"description,omitempty"`
	Source       string                    `yaml:"source,omitempty" json:"source,omitempty"`
	Details      map[string]string         `yaml:"details,omitempty" json:"details,omitempty"`
	Entity       string                    `yaml:"entity,omitempty" json:"entity,omitempty"`
	Responders   []OpsGenieConfigResponder `yaml:"responders,omitempty" json:"responders,omitempty"`
	Actions      string                    `yaml:"actions,omitempty" json:"actions,omitempty"`
	Tags         string                    `yaml:"tags,omitempty" json:"tags,omitempty"`
	Note         string                    `yaml:"note,omitempty" json:"note,omitempty"`
	Priority     string                    `yaml:"priority,omitempty" json:"priority,omitempty"`
	UpdateAlerts bool                      `yaml:"update_alerts,omitempty" json:"updateAlerts,omitempty"`
}

OpsGenieConfig configures notifications via OpsGenie.

func (*OpsGenieConfig) UnmarshalYAML

func (c *OpsGenieConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type OpsGenieConfigResponder

type OpsGenieConfigResponder struct {
	// One of those 3 should be filled.
	ID       string `yaml:"id,omitempty" json:"id,omitempty"`
	Name     string `yaml:"name,omitempty" json:"name,omitempty"`
	Username string `yaml:"username,omitempty" json:"username,omitempty"`

	// team, user, escalation, schedule etc.
	Type string `yaml:"type,omitempty" json:"type,omitempty"`
}

type PagerdutyConfig

type PagerdutyConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	ServiceKey     Secret            `yaml:"service_key,omitempty" json:"serviceKey,omitempty"`
	ServiceKeyFile string            `yaml:"service_key_file,omitempty" json:"serviceKeyFile,omitempty"`
	RoutingKey     Secret            `yaml:"routing_key,omitempty" json:"routingKey,omitempty"`
	RoutingKeyFile string            `yaml:"routing_key_file,omitempty" json:"routingKeyFile,omitempty"`
	URL            *URL              `yaml:"url,omitempty" json:"url,omitempty"`
	Client         string            `yaml:"client,omitempty" json:"client,omitempty"`
	ClientURL      string            `yaml:"client_url,omitempty" json:"clientUrl,omitempty"`
	Description    string            `yaml:"description,omitempty" json:"description,omitempty"`
	Details        map[string]string `yaml:"details,omitempty" json:"details,omitempty"`
	Images         []PagerdutyImage  `yaml:"images,omitempty" json:"images,omitempty"`
	Links          []PagerdutyLink   `yaml:"links,omitempty" json:"links,omitempty"`
	Source         string            `yaml:"source,omitempty" json:"source,omitempty"`
	Severity       string            `yaml:"severity,omitempty" json:"severity,omitempty"`
	Class          string            `yaml:"class,omitempty" json:"class,omitempty"`
	Component      string            `yaml:"component,omitempty" json:"component,omitempty"`
	Group          string            `yaml:"group,omitempty" json:"group,omitempty"`
}

PagerdutyConfig configures notifications via PagerDuty.

func (*PagerdutyConfig) UnmarshalYAML

func (c *PagerdutyConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type PagerdutyImage

type PagerdutyImage struct {
	Src  string `yaml:"src,omitempty" json:"src,omitempty"`
	Alt  string `yaml:"alt,omitempty" json:"alt,omitempty"`
	Href string `yaml:"href,omitempty" json:"href,omitempty"`
}

PagerdutyImage is an image

type PagerdutyLink struct {
	Href string `yaml:"href,omitempty" json:"href,omitempty"`
	Text string `yaml:"text,omitempty" json:"text,omitempty"`
}

PagerdutyLink is a link

type PushoverConfig

type PushoverConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	UserKey     Secret   `yaml:"user_key,omitempty" json:"userKey,omitempty"`
	UserKeyFile string   `yaml:"user_key_file,omitempty" json:"userKeyFile,omitempty"`
	Token       Secret   `yaml:"token,omitempty" json:"token,omitempty"`
	TokenFile   string   `yaml:"token_file,omitempty" json:"tokenFile,omitempty"`
	Title       string   `yaml:"title,omitempty" json:"title,omitempty"`
	Message     string   `yaml:"message,omitempty" json:"message,omitempty"`
	URL         string   `yaml:"url,omitempty" json:"url,omitempty"`
	URLTitle    string   `yaml:"url_title,omitempty" json:"urlTitle,omitempty"`
	Device      string   `yaml:"device,omitempty" json:"device,omitempty"`
	Sound       string   `yaml:"sound,omitempty" json:"sound,omitempty"`
	Priority    string   `yaml:"priority,omitempty" json:"priority,omitempty"`
	Retry       duration `yaml:"retry,omitempty" json:"retry,omitempty"`
	Expire      duration `yaml:"expire,omitempty" json:"expire,omitempty"`
	TTL         duration `yaml:"ttl,omitempty" json:"ttl,omitempty"`
	HTML        bool     `yaml:"html" json:"html,omitempty"`
}

func (*PushoverConfig) UnmarshalYAML

func (c *PushoverConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Receiver

type Receiver struct {
	// A unique identifier for this receiver.
	Name string `yaml:"name" json:"name" binding:"required"`

	EmailConfigs     []*EmailConfig     `yaml:"email_configs,omitempty" json:"emailConfigs,omitempty"`
	WebhookConfigs   []*WebhookConfig   `yaml:"webhook_configs,omitempty" json:"webhookConfigs,omitempty"`
	DingTalkConfigs  []*DingTalkConfig  `yaml:"-" json:"dingTalkConfigs,omitempty"`
	DiscordConfigs   []*DiscordConfig   `yaml:"discord_configs,omitempty" json:"-"`
	PagerdutyConfigs []*PagerdutyConfig `yaml:"pagerduty_configs,omitempty" json:"-"`
	SlackConfigs     []*SlackConfig     `yaml:"slack_configs,omitempty" json:"-"`
	OpsGenieConfigs  []*OpsGenieConfig  `yaml:"opsgenie_configs,omitempty" json:"-"`
	WechatConfigs    []*WechatConfig    `yaml:"wechat_configs,omitempty" json:"wechatConfigs,omitempty"`
	PushoverConfigs  []*PushoverConfig  `yaml:"pushover_configs,omitempty" json:"-"`
	VictorOpsConfigs []*VictorOpsConfig `yaml:"victorops_configs,omitempty" json:"-"`
	SNSConfigs       []*SNSConfig       `yaml:"sns_configs,omitempty" json:"-"`
	TelegramConfigs  []*TelegramConfig  `yaml:"telegram_configs,omitempty" json:"-"`
	WebexConfigs     []*WebexConfig     `yaml:"webex_configs,omitempty" json:"-"`
	MSTeamsConfigs   []*MSTeamsConfig   `yaml:"msteams_configs,omitempty" json:"-"`
}

Receiver configuration provides configuration on how to contact a receiver.

func (*Receiver) UnmarshalYAML

func (c *Receiver) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for Receiver.

type Regexp

type Regexp struct {
	*regexp.Regexp
	// contains filtered or unexported fields
}

Regexp encapsulates a regexp.Regexp and makes it YAML marshalable.

func (Regexp) MarshalJSON

func (re Regexp) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Regexp.

func (Regexp) MarshalYAML

func (re Regexp) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for Regexp.

func (*Regexp) UnmarshalJSON

func (re *Regexp) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for Regexp

func (*Regexp) UnmarshalYAML

func (re *Regexp) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for Regexp.

type Route

type Route struct {
	Receiver string `yaml:"receiver,omitempty" json:"receiver,omitempty"`

	GroupByStr []string          `yaml:"group_by,omitempty" json:"groupBy,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             MatchRegexps `yaml:"match_re,omitempty" json:"matchRe,omitempty"`
	Matchers            Matchers     `yaml:"matchers,omitempty" json:"matchers,omitempty"`
	MuteTimeIntervals   []string     `yaml:"mute_time_intervals,omitempty" json:"muteTimeIntervals,omitempty"`
	ActiveTimeIntervals []string     `yaml:"active_time_intervals,omitempty" json:"activeTimeIntervals,omitempty"`
	Continue            bool         `yaml:"continue" json:"continue,omitempty"`
	Routes              []*Route     `yaml:"routes,omitempty" json:"routes,omitempty"`

	GroupWait      *model.Duration `yaml:"group_wait,omitempty" json:"groupWait,omitempty"`
	GroupInterval  *model.Duration `yaml:"group_interval,omitempty" json:"groupInterval,omitempty"`
	RepeatInterval *model.Duration `yaml:"repeat_interval,omitempty" json:"repeatInterval,omitempty"`
}

A Route is a node that contains definitions of how to handle alerts.

func (*Route) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface for Route.

type SNSConfig

type SNSConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	APIUrl      string            `yaml:"api_url,omitempty" json:"apiUrl,omitempty"`
	Sigv4       sigv4.SigV4Config `yaml:"sigv4" json:"sigv4"`
	TopicARN    string            `yaml:"topic_arn,omitempty" json:"topicArn,omitempty"`
	PhoneNumber string            `yaml:"phone_number,omitempty" json:"phoneNumber,omitempty"`
	TargetARN   string            `yaml:"target_arn,omitempty" json:"targetArn,omitempty"`
	Subject     string            `yaml:"subject,omitempty" json:"subject,omitempty"`
	Message     string            `yaml:"message,omitempty" json:"message,omitempty"`
	Attributes  map[string]string `yaml:"attributes,omitempty" json:"attributes,omitempty"`
}

func (*SNSConfig) UnmarshalYAML

func (c *SNSConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Secret

type Secret string

type SlackAction

type SlackAction struct {
	Type         string                  `yaml:"type,omitempty"  json:"type,omitempty"`
	Text         string                  `yaml:"text,omitempty"  json:"text,omitempty"`
	URL          string                  `yaml:"url,omitempty"   json:"url,omitempty"`
	Style        string                  `yaml:"style,omitempty" json:"style,omitempty"`
	Name         string                  `yaml:"name,omitempty"  json:"name,omitempty"`
	Value        string                  `yaml:"value,omitempty"  json:"value,omitempty"`
	ConfirmField *SlackConfirmationField `yaml:"confirm,omitempty"  json:"confirm,omitempty"`
}

SlackAction configures a single Slack action that is sent with each notification. See https://api.slack.com/docs/message-attachments#action_fields and https://api.slack.com/docs/message-buttons for more information.

func (*SlackAction) UnmarshalYAML

func (c *SlackAction) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for SlackAction.

type SlackConfig

type SlackConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	APIURL     *URL   `yaml:"api_url,omitempty" json:"apiUrl,omitempty"`
	APIURLFile string `yaml:"api_url_file,omitempty" json:"apiUrlFile,omitempty"`

	// Slack channel override, (like #other-channel or @username).
	Channel  string `yaml:"channel,omitempty" json:"channel,omitempty"`
	Username string `yaml:"username,omitempty" json:"username,omitempty"`
	Color    string `yaml:"color,omitempty" json:"color,omitempty"`

	Title       string         `yaml:"title,omitempty" json:"title,omitempty"`
	TitleLink   string         `yaml:"title_link,omitempty" json:"titleLink,omitempty"`
	Pretext     string         `yaml:"pretext,omitempty" json:"pretext,omitempty"`
	Text        string         `yaml:"text,omitempty" json:"text,omitempty"`
	Fields      []*SlackField  `yaml:"fields,omitempty" json:"fields,omitempty"`
	ShortFields bool           `yaml:"short_fields" json:"shortFields,omitempty"`
	Footer      string         `yaml:"footer,omitempty" json:"footer,omitempty"`
	Fallback    string         `yaml:"fallback,omitempty" json:"fallback,omitempty"`
	CallbackID  string         `yaml:"callback_id,omitempty" json:"callbackId,omitempty"`
	IconEmoji   string         `yaml:"icon_emoji,omitempty" json:"iconEmoji,omitempty"`
	IconURL     string         `yaml:"icon_url,omitempty" json:"iconUrl,omitempty"`
	ImageURL    string         `yaml:"image_url,omitempty" json:"imageUrl,omitempty"`
	ThumbURL    string         `yaml:"thumb_url,omitempty" json:"thumbUrl,omitempty"`
	LinkNames   bool           `yaml:"link_names" json:"linkNames,omitempty"`
	MrkdwnIn    []string       `yaml:"mrkdwn_in,omitempty" json:"mrkdwnIn,omitempty"`
	Actions     []*SlackAction `yaml:"actions,omitempty" json:"actions,omitempty"`
}

SlackConfig configures notifications via Slack.

func (*SlackConfig) UnmarshalYAML

func (c *SlackConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type SlackConfirmationField

type SlackConfirmationField struct {
	Text        string `yaml:"text,omitempty"  json:"text,omitempty"`
	Title       string `yaml:"title,omitempty"  json:"title,omitempty"`
	OkText      string `yaml:"ok_text,omitempty"  json:"okText,omitempty"`
	DismissText string `yaml:"dismiss_text,omitempty"  json:"dismissText,omitempty"`
}

SlackConfirmationField protect users from destructive actions or particularly distinguished decisions by asking them to confirm their button click one more time. See https://api.slack.com/docs/interactive-message-field-guide#confirmation_fields for more information.

func (*SlackConfirmationField) UnmarshalYAML

func (c *SlackConfirmationField) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for SlackConfirmationField.

type SlackField

type SlackField struct {
	Title string `yaml:"title,omitempty" json:"title,omitempty"`
	Value string `yaml:"value,omitempty" json:"value,omitempty"`
	Short *bool  `yaml:"short,omitempty" json:"short,omitempty"`
}

SlackField configures a single Slack field that is sent with each notification. Each field must contain a title, value, and optionally, a boolean value to indicate if the field is short enough to be displayed next to other fields designated as short. See https://api.slack.com/docs/message-attachments#fields for more information.

func (*SlackField) UnmarshalYAML

func (c *SlackField) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for SlackField.

type TelegramConfig

type TelegramConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	APIUrl               *URL   `yaml:"api_url" json:"apiUrl,omitempty"`
	BotToken             Secret `yaml:"bot_token,omitempty" json:"token,omitempty"`
	BotTokenFile         string `yaml:"bot_token_file,omitempty" json:"tokenFile,omitempty"`
	ChatID               int64  `yaml:"chat_id,omitempty" json:"chat,omitempty"`
	Message              string `yaml:"message,omitempty" json:"message,omitempty"`
	DisableNotifications bool   `yaml:"disable_notifications,omitempty" json:"disableNotifications,omitempty"`
	ParseMode            string `yaml:"parse_mode,omitempty" json:"parseMode,omitempty"`
}

TelegramConfig configures notifications via Telegram.

func (*TelegramConfig) UnmarshalYAML

func (c *TelegramConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type TimeInterval

type TimeInterval struct {
	Name          string                      `yaml:"name" json:"name"`
	TimeIntervals []timeinterval.TimeInterval `yaml:"time_intervals" json:"timeIntervals"`
}

TimeInterval represents a named set of time intervals for which a route should be muted.

func (*TimeInterval) UnmarshalYAML

func (ti *TimeInterval) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for MuteTimeInterval.

type URL

type URL struct {
	// contains filtered or unexported fields
}

URL is a custom type that represents an HTTP or HTTPS URL and allows validation at configuration load time.

func (*URL) Copy

func (u *URL) Copy() *URL

Copy makes a deep-copy of the struct.

func (URL) MarshalJSON

func (u URL) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for URL.

func (URL) MarshalYAML

func (u URL) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface for URL.

func (*URL) String

func (u *URL) String() string

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Marshaler interface for URL.

func (*URL) UnmarshalYAML

func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface for URL.

type VictorOpsConfig

type VictorOpsConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	APIKey            Secret            `yaml:"api_key,omitempty" json:"apiKey,omitempty"`
	APIKeyFile        string            `yaml:"api_key_file,omitempty" json:"apiKeyFile,omitempty"`
	APIURL            *URL              `yaml:"api_url" json:"apiUrl"`
	RoutingKey        string            `yaml:"routing_key" json:"routingKey"`
	MessageType       string            `yaml:"message_type" json:"messageType"`
	StateMessage      string            `yaml:"state_message" json:"stateMessage"`
	EntityDisplayName string            `yaml:"entity_display_name" json:"entityDisplay_name"`
	MonitoringTool    string            `yaml:"monitoring_tool" json:"monitoringTool"`
	CustomFields      map[string]string `yaml:"custom_fields,omitempty" json:"customFields,omitempty"`
}

VictorOpsConfig configures notifications via VictorOps.

func (*VictorOpsConfig) UnmarshalYAML

func (c *VictorOpsConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type WebexConfig

type WebexConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`
	HTTPConfig     *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`
	APIURL         *URL                         `yaml:"api_url,omitempty" json:"apiUrl,omitempty"`

	Message string `yaml:"message,omitempty" json:"message,omitempty"`
	RoomID  string `yaml:"room_id" json:"roomId"`
}

WebexConfig configures notifications via Webex.

func (*WebexConfig) UnmarshalYAML

func (c *WebexConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type WebhookConfig

type WebhookConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	// URL to send POST request to.
	URL     *URL   `yaml:"url,omitempty" json:"url,omitempty"`
	URLFile string `yaml:"url_file,omitempty" json:"urlFile,omitempty"`

	// MaxAlerts is the maximum number of alerts to be sent per webhook message.
	// Alerts exceeding this threshold will be truncated. Setting this to 0
	// allows an unlimited number of alerts.
	MaxAlerts uint64 `yaml:"max_alerts" json:"maxAlerts"`
}

WebhookConfig configures notifications via a generic webhook.

func NewWebhookConfig

func NewWebhookConfig(urlStr string) *WebhookConfig

func (*WebhookConfig) UnmarshalJSON

func (c *WebhookConfig) UnmarshalJSON(data []byte) error

func (*WebhookConfig) UnmarshalYAML

func (c *WebhookConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type WechatConfig

type WechatConfig struct {
	NotifierConfig `yaml:",inline" json:",inline"`

	HTTPConfig *httpconfig.HTTPClientConfig `yaml:"http_config,omitempty" json:"httpConfig,omitempty"`

	APISecret   Secret `yaml:"api_secret,omitempty" json:"apiSecret,omitempty"`
	CorpID      string `yaml:"corp_id,omitempty" json:"corpId,omitempty"`
	Message     string `yaml:"message,omitempty" json:"message,omitempty"`
	APIURL      *URL   `yaml:"api_url,omitempty" json:"apiUrl,omitempty"`
	ToUser      string `yaml:"to_user,omitempty" json:"toUser,omitempty"`
	ToParty     string `yaml:"to_party,omitempty" json:"toParty,omitempty"`
	ToTag       string `yaml:"to_tag,omitempty" json:"toTag,omitempty"`
	AgentID     string `yaml:"agent_id,omitempty" json:"agentId,omitempty"`
	MessageType string `yaml:"message_type,omitempty" json:"messageType,omitempty"`
}

WechatConfig configures notifications via Wechat.

func (*WechatConfig) UnmarshalYAML

func (c *WechatConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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