Help us shape the future of Go! Take the 2026 Go Developer Survey

alertmanager

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: Apache-2.0 Imports: 3 Imported by: 2

Documentation

Overview

Package alertmanager provides utilities to work with Alertmanager's configuration

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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

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

func (*Config) Mask added in v0.2.5

func (c *Config) Mask() (*Config, error)

Mask masks sensitive data in Config.

type EmailConfig

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

	// Email address to notify.
	To           string               `yaml:"to,omitempty"`
	From         string               `yaml:"from,omitempty"`
	Hello        string               `yaml:"hello,omitempty"`
	Smarthost    string               `yaml:"smarthost,omitempty"`
	AuthUsername string               `yaml:"auth_username,omitempty" secret:"true"`
	AuthPassword string               `yaml:"auth_password,omitempty" secret:"true"`
	AuthSecret   string               `yaml:"auth_secret,omitempty" secret:"true"`
	AuthIdentity string               `yaml:"auth_identity,omitempty"`
	Headers      map[string]string    `yaml:"headers,omitempty"`
	HTML         string               `yaml:"html,omitempty"`
	Text         string               `yaml:"text,omitempty"`
	RequireTLS   *bool                `yaml:"require_tls,omitempty"`
	TLSConfig    promconfig.TLSConfig `yaml:"tls_config,omitempty"`
}

EmailConfig configures notifications via mail.

type GlobalConfig

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	SMTPFrom         string `yaml:"smtp_from,omitempty"`
	SMTPHello        string `yaml:"smtp_hello,omitempty"`
	SMTPSmarthost    string `yaml:"smtp_smarthost,omitempty"`
	SMTPAuthUsername string `yaml:"smtp_auth_username,omitempty" secret:"true"`
	SMTPAuthPassword string `yaml:"smtp_auth_password,omitempty" secret:"true"`
	SMTPAuthSecret   string `yaml:"smtp_auth_secret,omitempty"`
	SMTPAuthIdentity string `yaml:"smtp_auth_identity,omitempty"`
	SMTPRequireTLS   bool   `yaml:"smtp_require_tls"`
	SlackAPIURL      string `yaml:"slack_api_url,omitempty" secret:"true"`
	PagerdutyURL     string `yaml:"pagerduty_url,omitempty"`
	OpsGenieAPIURL   string `yaml:"opsgenie_api_url,omitempty"`
	OpsGenieAPIKey   string `yaml:"opsgenie_api_key,omitempty" secret:"true"`
	WeChatAPIURL     string `yaml:"wechat_api_url,omitempty"`
	WeChatAPISecret  string `yaml:"wechat_api_secret,omitempty" secret:"true"`
	WeChatAPICorpID  string `yaml:"wechat_api_corp_id,omitempty"`
	VictorOpsAPIURL  string `yaml:"victorops_api_url,omitempty"`
	VictorOpsAPIKey  string `yaml:"victorops_api_key,omitempty" secret:"true"`
}

GlobalConfig defines configuration parameters that are valid globally unless overwritten.

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,omitempty"`
	// SourceMatchRE defines pairs like SourceMatch but does regular expression
	// matching.
	SourceMatchRE map[string]string `yaml:"source_match_re,omitempty"`
	// TargetMatch defines a set of labels that have to equal the given
	// value for target alerts.
	TargetMatch map[string]string `yaml:"target_match,omitempty"`
	// TargetMatchRE defines pairs like TargetMatch but does regular expression
	// matching.
	TargetMatchRE map[string]string `yaml:"target_match_re,omitempty"`
	// A set of labels that must be equal between the source and target alert
	// for them to be a match.
	Equal string `yaml:"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.

type NotifierConfig

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

NotifierConfig contains base options common across all notifier configurations.

type OpsGenieConfig

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	APIKey      string                    `yaml:"api_key,omitempty" secret:"true"`
	APIURL      string                    `yaml:"api_url,omitempty"`
	Message     string                    `yaml:"message,omitempty"`
	Description string                    `yaml:"description,omitempty"`
	Source      string                    `yaml:"source,omitempty"`
	Details     map[string]string         `yaml:"details,omitempty"`
	Responders  []OpsGenieConfigResponder `yaml:"responders,omitempty"`
	Tags        string                    `yaml:"tags,omitempty"`
	Note        string                    `yaml:"note,omitempty"`
	Priority    string                    `yaml:"priority,omitempty"`
}

OpsGenieConfig configures notifications via OpsGenie.

type OpsGenieConfigResponder

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

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

OpsGenieConfigResponder returns configuration of OpsGenie responder.

type PagerdutyConfig

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	ServiceKey  string            `yaml:"service_key,omitempty" secret:"true"`
	RoutingKey  string            `yaml:"routing_key,omitempty" secret:"true"`
	URL         string            `yaml:"url,omitempty"`
	Client      string            `yaml:"client,omitempty"`
	ClientURL   string            `yaml:"client_url,omitempty"`
	Description string            `yaml:"description,omitempty"`
	Details     map[string]string `yaml:"details,omitempty"`
	Images      []PagerdutyImage  `yaml:"images,omitempty"`
	Links       []PagerdutyLink   `yaml:"links,omitempty"`
	Severity    string            `yaml:"severity,omitempty"`
	Class       string            `yaml:"class,omitempty"`
	Component   string            `yaml:"component,omitempty"`
	Group       string            `yaml:"group,omitempty"`
}

PagerdutyConfig configures notifications via PagerDuty.

type PagerdutyImage

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

PagerdutyImage is an image.

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

PagerdutyLink is a link.

type PushoverConfig

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	UserKey  string        `yaml:"user_key,omitempty" secret:"true"`
	Token    string        `yaml:"token,omitempty" secret:"true"`
	Title    string        `yaml:"title,omitempty"`
	Message  string        `yaml:"message,omitempty"`
	URL      string        `yaml:"url,omitempty"`
	URLTitle string        `yaml:"url_title,omitempty"`
	Sound    string        `yaml:"sound,omitempty"`
	Priority string        `yaml:"priority,omitempty"`
	Retry    time.Duration `yaml:"retry,omitempty"`
	Expire   time.Duration `yaml:"expire,omitempty"`
	HTML     bool          `yaml:"html"`
}

PushoverConfig configures notifications via PushOver.

type Receiver

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

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

Receiver configuration provides configuration on how to contact a receiver.

type Route

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

	GroupBy []string `yaml:"group_by,omitempty"`

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

	GroupWait      promconfig.Duration `yaml:"group_wait,omitempty"`
	GroupInterval  promconfig.Duration `yaml:"group_interval,omitempty"`
	RepeatInterval promconfig.Duration `yaml:"repeat_interval,omitempty"`
}

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

type SNSConfig added in v0.2.5

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

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

SNSConfig configures notifications via SNS.

type SigV4Config added in v0.2.5

type SigV4Config struct {
	Region    string `yaml:"region,omitempty"`
	AccessKey string `yaml:"access_key,omitempty"`
	SecretKey string `yaml:"secret_key,omitempty" secret:"true"`
	Profile   string `yaml:"profile,omitempty"`
	RoleARN   string `yaml:"role_arn,omitempty"`
}

SigV4Config is the configuration for signing remote write requests with AWS's SigV4 verification process. Empty values will be retrieved using the AWS default credentials chain.

type SlackAction

type SlackAction struct {
	Type         string                  `yaml:"type,omitempty"`
	Text         string                  `yaml:"text,omitempty"`
	URL          string                  `yaml:"url,omitempty"`
	Style        string                  `yaml:"style,omitempty"`
	Name         string                  `yaml:"name,omitempty"`
	Value        string                  `yaml:"value,omitempty"`
	ConfirmField *SlackConfirmationField `yaml:"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.

type SlackConfig

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	APIURL *string `yaml:"api_url,omitempty"`

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

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

SlackConfig configures notifications via Slack.

type SlackConfirmationField

type SlackConfirmationField struct {
	Text        string `yaml:"text,omitempty"`
	Title       string `yaml:"title,omitempty"`
	OkText      string `yaml:"ok_text,omitempty"`
	DismissText string `yaml:"dismiss_text,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.

type SlackField

type SlackField struct {
	Title string `yaml:"title,omitempty"`
	Value string `yaml:"value,omitempty"`
	Short *bool  `yaml:"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.

type TelegramConfig added in v0.2.5

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	APIUrl               *string `yaml:"api_url"`
	BotToken             string  `yaml:"bot_token,omitempty" secret:"true"`
	ChatID               int64   `yaml:"chat_id,omitempty"`
	Message              string  `yaml:"message,omitempty"`
	DisableNotifications bool    `yaml:"disable_notifications,omitempty"`
	ParseMode            string  `yaml:"parse_mode,omitempty"`
}

TelegramConfig configures notifications via Telegram.

type VictorOpsConfig

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	APIKey            string            `yaml:"api_key" secret:"true"`
	APIURL            string            `yaml:"api_url" secret:"true"`
	RoutingKey        string            `yaml:"routing_key"`
	MessageType       string            `yaml:"message_type"`
	StateMessage      string            `yaml:"state_message"`
	EntityDisplayName string            `yaml:"entity_display_name"`
	MonitoringTool    string            `yaml:"monitoring_tool"`
	CustomFields      map[string]string `yaml:"custom_fields,omitempty"`
}

VictorOpsConfig configures notifications via VictorOps.

type WebhookConfig

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	// URL to send POST request to.
	URL string `yaml:"url"`
	// 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"`
}

WebhookConfig configures notifications via a generic webhook.

type WechatConfig

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

	HTTPConfig promconfig.HTTPClientConfig `yaml:"http_config,omitempty"`

	APISecret   string `yaml:"api_secret,omitempty" secret:"true"`
	CorpID      string `yaml:"corp_id,omitempty"`
	Message     string `yaml:"message,omitempty"`
	APIURL      string `yaml:"api_url,omitempty"`
	ToUser      string `yaml:"to_user,omitempty"`
	ToParty     string `yaml:"to_party,omitempty"`
	ToTag       string `yaml:"to_tag,omitempty"`
	AgentID     string `yaml:"agent_id,omitempty"`
	MessageType string `yaml:"message_type,omitempty"`
}

WechatConfig configures notifications via Wechat.

Jump to

Keyboard shortcuts

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