alertmanager

package
v1.8.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: Apache-2.0 Imports: 66 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// RingKey is the key under which we store the alertmanager ring in the KVStore.
	RingKey = "alertmanager"

	// RingNameForServer is the name of the ring used by the alertmanager server.
	RingNameForServer = "alertmanager"

	// RingNumTokens is a safe default instead of exposing to config option to the user
	// in order to simplify the config.
	RingNumTokens = 128
)

Variables

View Source
var RingOp = ring.NewOp([]ring.IngesterState{ring.ACTIVE}, func(s ring.IngesterState) bool {

	return s != ring.ACTIVE
})

RingOp is the operation used for reading/writing to the alertmanagers.

Functions

This section is empty.

Types

type Alertmanager

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

An Alertmanager manages the alerts for one user.

func New

func New(cfg *Config, reg *prometheus.Registry) (*Alertmanager, error)

New creates a new Alertmanager.

func (*Alertmanager) ApplyConfig

func (am *Alertmanager) ApplyConfig(userID string, conf *config.Config, rawCfg string) error

ApplyConfig applies a new configuration to an Alertmanager.

func (*Alertmanager) Stop

func (am *Alertmanager) Stop()

Stop stops the Alertmanager.

func (*Alertmanager) StopAndWait added in v1.8.0

func (am *Alertmanager) StopAndWait()

type Client added in v1.8.0

type Client interface {
	alertmanagerpb.AlertmanagerClient

	// RemoteAddress returns the address of the remote alertmanager and is used to uniquely
	// identify an alertmanager instance.
	RemoteAddress() string
}

Client is the interface that should be implemented by any client used to read/write data to an alertmanager via GRPC.

type ClientConfig added in v1.8.0

type ClientConfig struct {
	RemoteTimeout time.Duration    `yaml:"remote_timeout"`
	TLSEnabled    bool             `yaml:"tls_enabled"`
	TLS           tls.ClientConfig `yaml:",inline"`
}

ClientConfig is the configuration struct for the alertmanager client.

func (*ClientConfig) RegisterFlagsWithPrefix added in v1.8.0

func (cfg *ClientConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)

RegisterFlagsWithPrefix registers flags with prefix.

type ClientsPool added in v1.8.0

type ClientsPool interface {
	// GetClientFor returns the alertmanager client for the given address.
	GetClientFor(addr string) (Client, error)
}

ClientsPool is the interface used to get the client from the pool for a specified address.

type ClusterConfig added in v1.7.0

type ClusterConfig struct {
	ListenAddr       string                 `yaml:"listen_address"`
	AdvertiseAddr    string                 `yaml:"advertise_address"`
	Peers            flagext.StringSliceCSV `yaml:"peers"`
	PeerTimeout      time.Duration          `yaml:"peer_timeout"`
	GossipInterval   time.Duration          `yaml:"gossip_interval"`
	PushPullInterval time.Duration          `yaml:"push_pull_interval"`
}

func (*ClusterConfig) RegisterFlags added in v1.7.0

func (cfg *ClusterConfig) RegisterFlags(f *flag.FlagSet)

func (*ClusterConfig) SupportDeprecatedFlagset added in v1.7.0

func (cfg *ClusterConfig) SupportDeprecatedFlagset(amCfg *MultitenantAlertmanagerConfig, logger log.Logger)

SupportDeprecatedFlagset ensures we support the previous set of cluster flags that are now deprecated.

type Config

type Config struct {
	UserID string
	// Used to persist notification logs and silences on disk.
	DataDir     string
	Logger      log.Logger
	Peer        *cluster.Peer
	PeerTimeout time.Duration
	Retention   time.Duration
	ExternalURL *url.URL
}

Config configures an Alertmanager.

type Distributor added in v1.8.0

type Distributor struct {
	services.Service
	// contains filtered or unexported fields
}

Distributor forwards requests to individual alertmanagers.

func NewDistributor added in v1.8.0

func NewDistributor(cfg ClientConfig, maxRecvMsgSize int64, alertmanagersRing *ring.Ring, alertmanagerClientsPool ClientsPool, logger log.Logger, reg prometheus.Registerer) (d *Distributor, err error)

NewDistributor constructs a new Distributor

func (*Distributor) DistributeRequest added in v1.8.0

func (d *Distributor) DistributeRequest(w http.ResponseWriter, r *http.Request)

DistributeRequest shards the writes and returns as soon as the quorum is satisfied. In case of reads, it proxies the request to one of the alertmanagers. DistributeRequest assumes that the caller has verified IsPathSupported returns true for the route.

func (*Distributor) IsPathSupported added in v1.8.0

func (d *Distributor) IsPathSupported(path string) bool

IsPathSupported returns true if the given route is currently supported by the Distributor.

type MultitenantAlertmanager

type MultitenantAlertmanager struct {
	services.Service
	// contains filtered or unexported fields
}

A MultitenantAlertmanager manages Alertmanager instances for multiple organizations.

func NewMultitenantAlertmanager

func NewMultitenantAlertmanager(cfg *MultitenantAlertmanagerConfig, store alertstore.AlertStore, logger log.Logger, registerer prometheus.Registerer) (*MultitenantAlertmanager, error)

NewMultitenantAlertmanager creates a new MultitenantAlertmanager.

func (*MultitenantAlertmanager) DeleteUserConfig added in v1.3.0

func (am *MultitenantAlertmanager) DeleteUserConfig(w http.ResponseWriter, r *http.Request)

DeleteUserConfig is exposed via user-visible API (if enabled, uses DELETE method), but also as an internal endpoint using POST method. Note that if no config exists for a user, StatusOK is returned.

func (*MultitenantAlertmanager) GetStatusHandler

func (am *MultitenantAlertmanager) GetStatusHandler() StatusHandler

GetStatusHandler returns the status handler for this multi-tenant alertmanager.

func (*MultitenantAlertmanager) GetUserConfig added in v1.3.0

func (am *MultitenantAlertmanager) GetUserConfig(w http.ResponseWriter, r *http.Request)

func (*MultitenantAlertmanager) HandleRequest added in v1.8.0

HandleRequest implements gRPC Alertmanager service, which receives request from AlertManager-Distributor.

func (*MultitenantAlertmanager) OnRingInstanceHeartbeat added in v1.7.0

func (r *MultitenantAlertmanager) OnRingInstanceHeartbeat(_ *ring.BasicLifecycler, _ *ring.Desc, _ *ring.InstanceDesc)

func (*MultitenantAlertmanager) OnRingInstanceRegister added in v1.7.0

func (r *MultitenantAlertmanager) OnRingInstanceRegister(_ *ring.BasicLifecycler, ringDesc ring.Desc, instanceExists bool, instanceID string, instanceDesc ring.InstanceDesc) (ring.IngesterState, ring.Tokens)

func (*MultitenantAlertmanager) OnRingInstanceStopping added in v1.7.0

func (r *MultitenantAlertmanager) OnRingInstanceStopping(_ *ring.BasicLifecycler)

func (*MultitenantAlertmanager) OnRingInstanceTokens added in v1.7.0

func (r *MultitenantAlertmanager) OnRingInstanceTokens(_ *ring.BasicLifecycler, _ ring.Tokens)

func (*MultitenantAlertmanager) RingHandler added in v1.7.0

func (am *MultitenantAlertmanager) RingHandler(w http.ResponseWriter, req *http.Request)

func (*MultitenantAlertmanager) ServeHTTP

func (am *MultitenantAlertmanager) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP serves the Alertmanager's web UI and API.

func (*MultitenantAlertmanager) SetUserConfig added in v1.3.0

func (am *MultitenantAlertmanager) SetUserConfig(w http.ResponseWriter, r *http.Request)

type MultitenantAlertmanagerConfig

type MultitenantAlertmanagerConfig struct {
	DataDir        string           `yaml:"data_dir"`
	Retention      time.Duration    `yaml:"retention"`
	ExternalURL    flagext.URLValue `yaml:"external_url"`
	PollInterval   time.Duration    `yaml:"poll_interval"`
	MaxRecvMsgSize int64            `yaml:"max_recv_msg_size"`

	DeprecatedClusterBindAddr      string              `yaml:"cluster_bind_address"`
	DeprecatedClusterAdvertiseAddr string              `yaml:"cluster_advertise_address"`
	DeprecatedPeers                flagext.StringSlice `yaml:"peers"`
	DeprecatedPeerTimeout          time.Duration       `yaml:"peer_timeout"`

	// Enable sharding for the Alertmanager
	ShardingEnabled bool       `yaml:"sharding_enabled"`
	ShardingRing    RingConfig `yaml:"sharding_ring"`

	FallbackConfigFile string `yaml:"fallback_config_file"`
	AutoWebhookRoot    string `yaml:"auto_webhook_root"`

	Store   alertstore.LegacyConfig `yaml:"storage"`
	Cluster ClusterConfig           `yaml:"cluster"`

	EnableAPI bool `yaml:"enable_api"`

	// For distributor.
	AlertmanagerClient ClientConfig `yaml:"alertmanager_client"`
}

MultitenantAlertmanagerConfig is the configuration for a multitenant Alertmanager.

func (*MultitenantAlertmanagerConfig) RegisterFlags

func (cfg *MultitenantAlertmanagerConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet.

func (*MultitenantAlertmanagerConfig) Validate added in v1.6.0

func (cfg *MultitenantAlertmanagerConfig) Validate() error

Validate config and returns error on failure

type NilChannel added in v1.8.0

type NilChannel struct{}

func (*NilChannel) Broadcast added in v1.8.0

func (c *NilChannel) Broadcast([]byte)

type NilPeer added in v1.8.0

type NilPeer struct{}

NilPeer and NilChannel implements the Alertmanager clustering interface used by the API to expose cluster information. In a multi-tenant environment, we choose not to expose these to tenants and thus are not implemented.

func (*NilPeer) AddState added in v1.8.0

func (*NilPeer) Name added in v1.8.0

func (p *NilPeer) Name() string

func (*NilPeer) Peers added in v1.8.0

func (p *NilPeer) Peers() []cluster.ClusterMember

func (*NilPeer) Position added in v1.8.0

func (p *NilPeer) Position() int

func (*NilPeer) Status added in v1.8.0

func (p *NilPeer) Status() string

func (*NilPeer) WaitReady added in v1.8.0

func (p *NilPeer) WaitReady()

type RingConfig added in v1.7.0

type RingConfig struct {
	KVStore           kv.Config     `yaml:"kvstore" doc:"description=The key-value store used to share the hash ring across multiple instances."`
	HeartbeatPeriod   time.Duration `yaml:"heartbeat_period"`
	HeartbeatTimeout  time.Duration `yaml:"heartbeat_timeout"`
	ReplicationFactor int           `yaml:"replication_factor"`

	// Instance details
	InstanceID             string   `yaml:"instance_id" doc:"hidden"`
	InstanceInterfaceNames []string `yaml:"instance_interface_names"`
	InstancePort           int      `yaml:"instance_port" doc:"hidden"`
	InstanceAddr           string   `yaml:"instance_addr" doc:"hidden"`

	// Injected internally
	ListenPort      int           `yaml:"-"`
	RingCheckPeriod time.Duration `yaml:"-"`

	// Used for testing
	SkipUnregister bool `yaml:"-"`
}

RingConfig masks the ring lifecycler config which contains many options not really required by the alertmanager ring. This config is used to strip down the config to the minimum, and avoid confusion to the user.

func (*RingConfig) RegisterFlags added in v1.7.0

func (cfg *RingConfig) RegisterFlags(f *flag.FlagSet)

RegisterFlags adds the flags required to config this to the given FlagSet

func (*RingConfig) ToLifecyclerConfig added in v1.7.0

func (cfg *RingConfig) ToLifecyclerConfig() (ring.BasicLifecyclerConfig, error)

ToLifecyclerConfig returns a LifecyclerConfig based on the alertmanager ring config.

func (*RingConfig) ToRingConfig added in v1.7.0

func (cfg *RingConfig) ToRingConfig() ring.Config

type StatusHandler

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

StatusHandler shows the status of the alertmanager.

func (StatusHandler) ServeHTTP

func (s StatusHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP serves the status of the alertmanager.

type UserConfig added in v1.3.0

type UserConfig struct {
	TemplateFiles      map[string]string `yaml:"template_files"`
	AlertmanagerConfig string            `yaml:"alertmanager_config"`
}

UserConfig is used to communicate a users alertmanager configs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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