config

package
v0.0.0-...-09a90c1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2016 License: Apache-2.0 Imports: 9 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,
		},
	}

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

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

	// 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" . }}`,
		Details: 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 }}`,
		},
	}

	// DefaultSMSConfig defines default values for SMS configurations.
	DefaultSMSConfig = SMSConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: false,
		},
		Text: `{{ template "sms.default.text" . }}`,
	}

	// 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" . }}`,
		Pretext:   `{{ template "slack.default.pretext" . }}`,
		Text:      `{{ template "slack.default.text" . }}`,
		Fallback:  `{{ template "slack.default.fallback" . }}`,
	}

	//DefaultCallConfig defines default valus for call
	DefaultCallConfig = CallConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: false,
		},
		Message: `{{template "call.default.fallback" .}}`,
	}

	// DefaultHipchatConfig defines default values for Hipchat configurations.
	DefaultHipchatConfig = HipchatConfig{
		NotifierConfig: NotifierConfig{
			VSendResolved: false,
		},
		Color:         `{{ if eq .Status "firing" }}red{{ else }}green{{ end }}`,
		From:          `{{ template "hipchat.default.from" . }}`,
		Notify:        false,
		Message:       `{{ template "hipchat.default.message" . }}`,
		MessageFormat: `text`,
	}

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

	// 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),
	}
)
View Source
var DefaultGlobalConfig = GlobalConfig{
	ResolveTimeout: model.Duration(5 * time.Minute),

	PagerdutyURL:    "https://events.pagerduty.com/generic/2010-04-15/create_event.json",
	HipchatURL:      "https://api.hipchat.com/",
	OpsGenieAPIHost: "https://api.opsgenie.com/",
}

DefaultGlobalConfig provides global default values.

Functions

This section is empty.

Types

type CallConfig

type CallConfig struct {
	NotifierConfig `yaml:",inline"`

	// Slack channel override, (like #other-channel or @username).
	From           string `yaml:"from"`
	To             string `yaml:"to"`
	Message        string `yaml:"message"`
	SuffixToken    Secret `yaml:"suffix_token"`
	SuffixUsername string `yaml:"suffix_username"`
	SuffixAccount  string `yaml:"suffix_account"`
	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

CallConfig configures notifications via Call.

func (*CallConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Config

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

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
	// 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.

type EmailConfig

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

	// Email address to notify.
	To           string            `yaml:"to"`
	From         string            `yaml:"from"`
	Smarthost    string            `yaml:"smarthost,omitempty"`
	AuthUsername string            `yaml:"auth_username"`
	AuthPassword Secret            `yaml:"auth_password"`
	AuthSecret   Secret            `yaml:"auth_secret"`
	AuthIdentity string            `yaml:"auth_identity"`
	Headers      map[string]string `yaml:"headers"`
	HTML         string            `yaml:"html"`
	RequireTLS   bool              `yaml:"require_tls"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

EmailConfig configures notifications via mail.

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

	SMTPFrom         string `yaml:"smtp_from"`
	SMTPSmarthost    string `yaml:"smtp_smarthost"`
	SMTPAuthUsername string `yaml:"smtp_auth_username"`
	SMTPAuthPassword Secret `yaml:"smtp_auth_password"`
	SMTPAuthSecret   Secret `yaml:"smtp_auth_secret"`
	SMTPAuthIdentity string `yaml:"smtp_auth_identity"`
	SlackAPIURL      Secret `yaml:"slack_api_url"`
	PagerdutyURL     string `yaml:"pagerduty_url"`
	HipchatURL       string `yaml:"hipchat_url"`
	SMSAccountSID    string `yaml:"sms_account_sid"`
	SMSAccountToken  Secret `yaml:"sms_account_token"`
	HipchatAuthToken Secret `yaml:"hipchat_auth_token"`
	OpsGenieAPIHost  string `yaml:"opsgenie_api_host"`
	SuffixUsername   string `yaml:"suffix_username"`
	SuffixToken      Secret `yaml:"suffix_token"`
	SuffixAccount    string `yaml:"suffix_account"`
}

GlobalConfig defines configuration parameters that are valid globally unless overwritten.

func (*GlobalConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type HipchatConfig

type HipchatConfig struct {
	NotifierConfig `yaml:",inline"`

	APIURL        string `yaml:"api_url"`
	AuthToken     Secret `yaml:"auth_token"`
	RoomID        string `yaml:"room_id"`
	From          string `yaml:"from"`
	Notify        bool   `yaml:"notify"`
	Message       string `yaml:"message"`
	MessageFormat string `yaml:"message_format"`
	Color         string `yaml:"color"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

HipchatConfig configures notifications via Hipchat.

func (*HipchatConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type InhibitRule

type InhibitRule struct {
	// SourceMatch defines a set of labels that have to equal the given
	// value for source alerts.
	SourceMatch map[string]string `yaml:"source_match"`
	// SourceMatchRE defines pairs like SourceMatch but does regular expression
	// matching.
	SourceMatchRE map[string]Regexp `yaml:"source_match_re"`
	// TargetMatch defines a set of labels that have to equal the given
	// value for target alerts.
	TargetMatch map[string]string `yaml:"target_match"`
	// TargetMatchRE defines pairs like TargetMatch but does regular expression
	// matching.
	TargetMatchRE map[string]Regexp `yaml:"target_match_re"`
	// 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"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

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.

type NotifierConfig

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

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

	APIKey      Secret            `yaml:"api_key"`
	APIHost     string            `yaml:"api_host"`
	Description string            `yaml:"description"`
	Source      string            `yaml:"source"`
	Details     map[string]string `yaml:"details"`
	Teams       string            `yaml:"teams"`
	Tags        string            `yaml:"tags"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

OpsGenieConfig configures notifications via OpsGenie.

func (*OpsGenieConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type PagerdutyConfig

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

	ServiceKey  Secret            `yaml:"service_key"`
	URL         string            `yaml:"url"`
	Client      string            `yaml:"client"`
	ClientURL   string            `yaml:"client_url"`
	Description string            `yaml:"description"`
	Details     map[string]string `yaml:"details"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

PagerdutyConfig configures notifications via PagerDuty.

func (*PagerdutyConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type PushoverConfig

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

	UserKey  Secret   `yaml:"user_key"`
	Token    Secret   `yaml:"token"`
	Title    string   `yaml:"title"`
	Message  string   `yaml:"message"`
	URL      string   `yaml:"url"`
	Priority string   `yaml:"priority"`
	Retry    duration `yaml:"retry"`
	Expire   duration `yaml:"expire"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

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"`
	EmailConfigs     []*EmailConfig     `yaml:"email_configs,omitempty"`
	SMSConfigs       []*SMSConfig       `yaml:"sms_configs,omitempty"`
	PagerdutyConfigs []*PagerdutyConfig `yaml:"pagerduty_configs,omitempty"`
	HipchatConfigs   []*HipchatConfig   `yaml:"hipchat_configs,omitempty"`
	SlackConfigs     []*SlackConfig     `yaml:"slack_configs,omitempty"`
	CallConfigs      []*CallConfig      `yaml:"call_configs,omitempty"`
	WebhookConfigs   []*WebhookConfig   `yaml:"webhook_configs,omitempty"`
	OpsGenieConfigs  []*OpsGenieConfig  `yaml:"opsgenie_configs,omitempty"`
	PushoverConfigs  []*PushoverConfig  `yaml:"pushover_configs,omitempty"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

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.

type Regexp

type Regexp struct {
	*regexp.Regexp
}

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

func (*Regexp) MarshalYAML

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

MarshalYAML implements the yaml.Marshaler interface.

func (*Regexp) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Route

type Route struct {
	Receiver string            `yaml:"receiver,omitempty"`
	GroupBy  []model.LabelName `yaml:"group_by,omitempty"`

	Match    map[string]string `yaml:"match,omitempty"`
	MatchRE  map[string]Regexp `yaml:"match_re,omitempty"`
	Continue bool              `yaml:"continue,omitempty"`
	Routes   []*Route          `yaml:"routes,omitempty"`

	GroupWait      *model.Duration `yaml:"group_wait,omitempty"`
	GroupInterval  *model.Duration `yaml:"group_interval,omitempty"`
	RepeatInterval *model.Duration `yaml:"repeat_interval,omitempty"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

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.

type SMSConfig

type SMSConfig struct {
	NotifierConfig `yaml:",inline"`
	// Exotel sid and token
	AccountSID   string `yaml:"account_sid"`
	AccountToken Secret `yaml:"account_token"`
	// number to which sms has to be sent
	To   string `yaml:"to"`
	From string `yml:"from"`
	Text string `yaml:"text"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

SMSConfig configures notifications via SMS using exotel.

func (*SMSConfig) UnmarshalYAML

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

type Secret

type Secret string

Secret is a string that must not be revealed on marshaling.

func (Secret) MarshalYAML

func (s Secret) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface.

type SlackConfig

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

	APIURL Secret `yaml:"api_url"`

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

	Title     string `yaml:"title"`
	TitleLink string `yaml:"title_link"`
	Pretext   string `yaml:"pretext"`
	Text      string `yaml:"text"`
	Fallback  string `yaml:"fallback"`
	IconEmoji string `yaml:"icon_emoji"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

SlackConfig configures notifications via Slack.

func (*SlackConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

type WebhookConfig

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

	// URL to send POST request to.
	URL string `yaml:"url"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

WebhookConfig configures notifications via a generic webhook.

func (*WebhookConfig) UnmarshalYAML

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

UnmarshalYAML implements the yaml.Unmarshaler interface.

Jump to

Keyboard shortcuts

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