config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSMTPServerHost = "localhost"
View Source
const DefaultSMTPServerPort = 25

Variables

View Source
var (
	DefaultSlackConfig = SlackConfig{
		NotifierConfig: cfg.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" . }}`,
	}
	// DefaultEmailConfig defines default values for Email configurations.
	DefaultEmailConfig = EmailConfig{
		NotifierConfig: cfg.NotifierConfig{
			VSendResolved: false,
		},
		HTML: `{{ template "email.default.html" . }}`,
		Text: ``,
	}
)

Functions

This section is empty.

Types

type ConfigMapData

type ConfigMapData struct {
	Global       *GlobalConfig      `yaml:"global,omitempty" json:"global,omitempty"`
	Route        *cfg.Route         `yaml:"route,omitempty" json:"route,omitempty"`
	InhibitRules []*cfg.InhibitRule `yaml:"inhibit_rules,omitempty" json:"inhibit_rules,omitempty"`
	Receivers    []*Receiver        `yaml:"receivers,omitempty" json:"receivers,omitempty"`
	Templates    []string           `yaml:"templates" json:"templates"`
}

Mimics github.com/prometheus/alertmanager/config/config.go's Config struct but we can't due to mismatched github.com/prometheus/common versions

func NewConfigMapDataFrom

func NewConfigMapDataFrom(data string) (*ConfigMapData, error)

func (*ConfigMapData) AppendReceiver

func (c *ConfigMapData) AppendReceiver(recv *Receiver)

func (*ConfigMapData) AppendRoute

func (c *ConfigMapData) AppendRoute(recv *Receiver, req *alertingv1alpha.CreateImplementation)

func (*ConfigMapData) DeleteReceiver

func (c *ConfigMapData) DeleteReceiver(id string) error

func (*ConfigMapData) DeleteRoute

func (c *ConfigMapData) DeleteRoute(id string) error

func (*ConfigMapData) GetReceivers

func (c *ConfigMapData) GetReceivers() []*Receiver

func (*ConfigMapData) GetRoutes

func (c *ConfigMapData) GetRoutes() []*cfg.Route

func (*ConfigMapData) Marshal

func (c *ConfigMapData) Marshal() ([]byte, error)

func (*ConfigMapData) Parse

func (c *ConfigMapData) Parse(data string) error

func (*ConfigMapData) SetDefaultSMTPFrom

func (c *ConfigMapData) SetDefaultSMTPFrom()

func (*ConfigMapData) SetDefaultSMTPServer

func (c *ConfigMapData) SetDefaultSMTPServer()

func (*ConfigMapData) UnsetSMTPServer

func (c *ConfigMapData) UnsetSMTPServer()

func (*ConfigMapData) UpdateReceiver

func (c *ConfigMapData) UpdateReceiver(id string, recv *Receiver) error

func (*ConfigMapData) UpdateRoute

func (c *ConfigMapData) UpdateRoute(id string, recv *Receiver, req *alertingv1alpha.CreateImplementation) error

type EmailConfig

type EmailConfig struct {
	cfg.NotifierConfig `yaml:",inline" json:",inline"`
	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          cfg.HostPort `yaml:"smarthost,omitempty" json:"smarthost,omitempty"`
	AuthUsername       string       `yaml:"auth_username,omitempty" json:"auth_username,omitempty"`
	// Change from secret to string since the string is stored in a kube secret anyways
	AuthPassword string `yaml:"auth_password,omitempty" json:"auth_password,omitempty"`
	// Change from secret to string since the string is stored in a kube secret anyways
	AuthSecret   string            `yaml:"auth_secret,omitempty" json:"auth_secret,omitempty"`
	AuthIdentity string            `yaml:"auth_identity,omitempty" json:"auth_identity,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:"require_tls,omitempty"`
	TLSConfig    config.TLSConfig  `yaml:"tls_config,omitempty" json:"tls_config,omitempty"`
}

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

	HTTPConfig *HTTPClientConfig `yaml:"http_config,omitempty" json:"http_config,omitempty"`

	SMTPFrom         string       `yaml:"smtp_from,omitempty" json:"smtp_from,omitempty"`
	SMTPHello        string       `yaml:"smtp_hello,omitempty" json:"smtp_hello,omitempty"`
	SMTPSmarthost    cfg.HostPort `yaml:"smtp_smarthost,omitempty" json:"smtp_smarthost,omitempty"`
	SMTPAuthUsername string       `yaml:"smtp_auth_username,omitempty" json:"smtp_auth_username,omitempty"`
	// Changed from Secret to string to avoid issues with the yaml parser
	SMTPAuthPassword string `yaml:"smtp_auth_password,omitempty" json:"smtp_auth_password,omitempty"`
	// Changed from Secret to string to avoid issues with the yaml parser
	SMTPAuthSecret     string         `yaml:"smtp_auth_secret,omitempty" json:"smtp_auth_secret,omitempty"`
	SMTPAuthIdentity   string         `yaml:"smtp_auth_identity,omitempty" json:"smtp_auth_identity,omitempty"`
	SMTPRequireTLS     bool           `yaml:"smtp_require_tls" json:"smtp_require_tls,omitempty"`
	SlackAPIURL        *cfg.SecretURL `yaml:"slack_api_url,omitempty" json:"slack_api_url,omitempty"`
	SlackAPIURLFile    string         `yaml:"slack_api_url_file,omitempty" json:"slack_api_url_file,omitempty"`
	PagerdutyURL       *cfg.URL       `yaml:"pagerduty_url,omitempty" json:"pagerduty_url,omitempty"`
	OpsGenieAPIURL     *cfg.URL       `yaml:"opsgenie_api_url,omitempty" json:"opsgenie_api_url,omitempty"`
	OpsGenieAPIKey     cfg.Secret     `yaml:"opsgenie_api_key,omitempty" json:"opsgenie_api_key,omitempty"`
	OpsGenieAPIKeyFile string         `yaml:"opsgenie_api_key_file,omitempty" json:"opsgenie_api_key_file,omitempty"`
	WeChatAPIURL       *cfg.URL       `yaml:"wechat_api_url,omitempty" json:"wechat_api_url,omitempty"`
	WeChatAPISecret    cfg.Secret     `yaml:"wechat_api_secret,omitempty" json:"wechat_api_secret,omitempty"`
	WeChatAPICorpID    string         `yaml:"wechat_api_corp_id,omitempty" json:"wechat_api_corp_id,omitempty"`
	VictorOpsAPIURL    *cfg.URL       `yaml:"victorops_api_url,omitempty" json:"victorops_api_url,omitempty"`
	VictorOpsAPIKey    cfg.Secret     `yaml:"victorops_api_key,omitempty" json:"victorops_api_key,omitempty"`
	TelegramAPIUrl     *cfg.URL       `yaml:"telegram_api_url,omitempty" json:"telegram_api_url,omitempty"`
}

required due to https://github.com/rancher/opni/issues/542

func DefaultGlobalConfig

func DefaultGlobalConfig() GlobalConfig

type HTTPClientConfig

type HTTPClientConfig struct {
	// The HTTP basic authentication credentials for the targets.
	BasicAuth *commoncfg.BasicAuth `yaml:"basic_auth,omitempty" json:"basic_auth,omitempty"`
	// The HTTP authorization credentials for the targets.
	Authorization *commoncfg.Authorization `yaml:"authorization,omitempty" json:"authorization,omitempty"`
	// The OAuth2 client credentials used to fetch a token for the targets.
	OAuth2 *commoncfg.OAuth2 `yaml:"oauth2,omitempty" json:"oauth2,omitempty"`
	// The bearer token for the targets. Deprecated in favour of
	// Authorization.Credentials.
	BearerToken commoncfg.Secret `yaml:"bearer_token,omitempty" json:"bearer_token,omitempty"`
	// The bearer token file for the targets. Deprecated in favour of
	// Authorization.CredentialsFile.
	BearerTokenFile string `yaml:"bearer_token_file,omitempty" json:"bearer_token_file,omitempty"`
	// HTTP proxy server to use to connect to the targets.
	ProxyURL commoncfg.URL `yaml:"proxy_url,omitempty" json:"proxy_url,omitempty"`
	// TLSConfig to use to connect to the targets.
	TLSConfig commoncfg.TLSConfig `yaml:"tls_config,omitempty" json:"tls_config,omitempty"`
	// FollowRedirects specifies whether the client should follow HTTP 3xx redirects.
	// The omitempty flag is not set, because it would be hidden from the
	// marshalled configuration when set to false.
	FollowRedirects bool `yaml:"follow_redirects" json:"follow_redirects"`
}

required due to https://github.com/rancher/opni/issues/542

type Receiver

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

	EmailConfigs     []*EmailConfig         `yaml:"email_configs,omitempty" json:"email_configs,omitempty"`
	PagerdutyConfigs []*cfg.PagerdutyConfig `yaml:"pagerduty_configs,omitempty" json:"pagerduty_configs,omitempty"`
	SlackConfigs     []*SlackConfig         `yaml:"slack_configs,omitempty" json:"slack_configs,omitempty"`
	WebhookConfigs   []*cfg.WebhookConfig   `yaml:"webhook_configs,omitempty" json:"webhook_configs,omitempty"`
	OpsGenieConfigs  []*cfg.OpsGenieConfig  `yaml:"opsgenie_configs,omitempty" json:"opsgenie_configs,omitempty"`
	WechatConfigs    []*cfg.WechatConfig    `yaml:"wechat_configs,omitempty" json:"wechat_configs,omitempty"`
	PushoverConfigs  []*cfg.PushoverConfig  `yaml:"pushover_configs,omitempty" json:"pushover_configs,omitempty"`
	VictorOpsConfigs []*cfg.VictorOpsConfig `yaml:"victorops_configs,omitempty" json:"victorops_configs,omitempty"`
	SNSConfigs       []*cfg.SNSConfig       `yaml:"sns_configs,omitempty" json:"sns_configs,omitempty"`
	TelegramConfigs  []*cfg.TelegramConfig  `yaml:"telegram_configs,omitempty" json:"telegram_configs,omitempty"`
}

Receiver configuration provides configuration on how to contact a receiver. Required to overwrite certain fields in alertmanager's Receiver : https://github.com/rancher/opni/issues/544

func NewEmailReceiver

func NewEmailReceiver(id string, endpoint *alertingv1alpha.EmailEndpoint) (*Receiver, error)

func NewSlackReceiver

func NewSlackReceiver(id string, endpoint *alertingv1alpha.SlackEndpoint) (*Receiver, error)

func NewWebhookReceiver

func NewWebhookReceiver(id string, endpoint *alertingv1alpha.WebhookEndpoint) (*Receiver, error)

NewWebhookReceiver creates a new receiver for the webhook endpoint

func WithEmailImplementation

func WithEmailImplementation(recv *Receiver, impl *alertingv1alpha.EndpointImplementation) (*Receiver, error)

func WithSlackImplementation

func WithSlackImplementation(
	recv *Receiver,
	impl *alertingv1alpha.EndpointImplementation,
) (*Receiver, error)

func (*Receiver) UnmarshalYAML

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

type SlackConfig

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

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

	// string since the string is stored in a kube secret anyways
	APIURL     string `yaml:"api_url,omitempty" json:"api_url,omitempty"`
	APIURLFile string `yaml:"api_url_file,omitempty" json:"api_url_file,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:"title_link,omitempty"`
	Pretext     string             `yaml:"pretext,omitempty" json:"pretext,omitempty"`
	Text        string             `yaml:"text,omitempty" json:"text,omitempty"`
	Fields      []*cfg.SlackField  `yaml:"fields,omitempty" json:"fields,omitempty"`
	ShortFields bool               `yaml:"short_fields" json:"short_fields,omitempty"`
	Footer      string             `yaml:"footer,omitempty" json:"footer,omitempty"`
	Fallback    string             `yaml:"fallback,omitempty" json:"fallback,omitempty"`
	CallbackID  string             `yaml:"callback_id,omitempty" json:"callback_id,omitempty"`
	IconEmoji   string             `yaml:"icon_emoji,omitempty" json:"icon_emoji,omitempty"`
	IconURL     string             `yaml:"icon_url,omitempty" json:"icon_url,omitempty"`
	ImageURL    string             `yaml:"image_url,omitempty" json:"image_url,omitempty"`
	ThumbURL    string             `yaml:"thumb_url,omitempty" json:"thumb_url,omitempty"`
	LinkNames   bool               `yaml:"link_names" json:"link_names,omitempty"`
	MrkdwnIn    []string           `yaml:"mrkdwn_in,omitempty" json:"mrkdwn_in,omitempty"`
	Actions     []*cfg.SlackAction `yaml:"actions,omitempty" json:"actions,omitempty"`
}

func (*SlackConfig) UnmarshalYAML

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

Jump to

Keyboard shortcuts

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