notify

package
v0.0.0-...-e59bb6d Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: AGPL-3.0 Imports: 123 Imported by: 8

Documentation

Index

Constants

View Source
const (
	DefaultReceiverName    = "TestReceiver"
	DefaultGroupLabel      = "group_label"
	DefaultGroupLabelValue = "group_label_value"
	MaxTemplateOutputSize  = 1024 * 1024 // 1MB
)
View Source
const ActiveStateLabelValue = "active"
View Source
const InactiveStateLabelValue = "inactive"

Variables

View Source
var (
	ErrGetAlertsInternal        = fmt.Errorf("unable to retrieve alerts(s) due to an internal error")
	ErrGetAlertsUnavailable     = fmt.Errorf("unable to retrieve alerts(s) as alertmanager is not initialised yet")
	ErrGetAlertsBadPayload      = fmt.Errorf("unable to retrieve alerts")
	ErrGetAlertGroupsBadPayload = fmt.Errorf("unable to retrieve alerts groups")
)
View Source
var (
	ErrGetSilencesInternal     = fmt.Errorf("unable to retrieve silence(s) due to an internal error")
	ErrDeleteSilenceInternal   = fmt.Errorf("unable to delete silence due to an internal error")
	ErrCreateSilenceBadPayload = fmt.Errorf("unable to create silence")
	ErrListSilencesBadPayload  = fmt.Errorf("unable to list silences")
	ErrSilenceNotFound         = silence.ErrNotFound
)
View Source
var (
	ErrNoReceivers = errors.New("no receivers")
)
View Source
var (
	ErrUnknownIntegrationType = fmt.Errorf("unknown integration type")
)
View Source
var NewIntegration = nfstatus.NewIntegration
View Source
var OpenAPIAlertsToAlerts = v2.OpenAPIAlertsToAlerts

Functions

func BuildPrometheusReceiverIntegrations

func BuildPrometheusReceiverIntegrations(
	nc definition.Receiver,
	tmplProvider TemplatesProvider,
	httpClientOptions []http.ClientOption,
	logger log.Logger,
	wrapper WrapNotifierFunc,
	notificationHistorian nfstatus.NotificationHistorian,
) ([]*nfstatus.Integration, error)

BuildPrometheusReceiverIntegrations builds a list of integration notifiers off of a receiver config. Taken from https://github.com/grafana/mimir/blob/fa489e696481fe0b7b97598077565dc5027afa84/pkg/alertmanager/alertmanager.go#L754 which is taken from https://github.com/prometheus/alertmanager/blob/94d875f1227b29abece661db1a68c001122d1da5/cmd/alertmanager/main.go#L112-L159.

func BuildReceiversIntegrations

func BuildReceiversIntegrations(
	tenantID int64,
	apiReceivers []*APIReceiver,
	templ TemplatesProvider,
	images images.Provider,
	decryptFn GetDecryptedValueFn,
	decodeFn DecodeSecretsFn,
	emailSender receivers.EmailSender,
	httpClientOptions []http.ClientOption,
	notifierFunc WrapNotifierFunc,
	version string,
	logger log.Logger,
	notificationHistorian nfstatus.NotificationHistorian,
) (map[string][]*Integration, error)

BuildReceiversIntegrations builds integrations for the provided API receivers and returns them mapped by receiver name. It ensures uniqueness of receivers by the name, overwriting duplicates and logs warnings. Returns an error if any integration fails during its construction.

func DecodeSecretsFromBase64

func DecodeSecretsFromBase64(secrets map[string]string) (map[string][]byte, error)

DecodeSecretsFromBase64 is a DecodeSecretsFn that base64-decodes a map of secrets.

func GetActiveReceiversMap

func GetActiveReceiversMap(r *dispatch.Route) map[string]struct{}

GetActiveReceiversMap returns all receivers that are in use by a route.

func GetDecryptedValueFnForTesting

func GetDecryptedValueFnForTesting(_ context.Context, sjd map[string][]byte, key string, fallback string) string

func GetReceivers

func GetReceivers(receivers []*nfstatus.Receiver) []models.ReceiverStatus

GetReceivers converts the internal receiver status into the API response.

func GetSchemaForAllIntegrations

func GetSchemaForAllIntegrations() []schema.IntegrationTypeSchema

GetSchemaForAllIntegrations returns all known schema sorted by the main type.

func GetSchemaForIntegration

func GetSchemaForIntegration(integrationType schema.IntegrationType) (schema.IntegrationTypeSchema, bool)

GetSchemaForIntegration returns the schema for a specific integration type of its alias.

func GetSchemaVersionForIntegration

func GetSchemaVersionForIntegration(integrationType schema.IntegrationType, version schema.Version) (schema.IntegrationSchemaVersion, bool)

GetSchemaVersionForIntegration returns the schema version for a specific integration type and version.

func IntegrationTypeFromMimirType

func IntegrationTypeFromMimirType(t any) (schema.IntegrationType, error)

IntegrationTypeFromMimirType returns a valid integration type from a type. The argument could be a slice of configurations, e.g. Receiver.EmailConfigs or a struct or a pointer of config type, e.g. config.EmailConfig The returning type could be alias or original type.

func IntegrationTypeFromMimirTypeReflect

func IntegrationTypeFromMimirTypeReflect(t reflect.Type) (schema.IntegrationType, error)

IntegrationTypeFromMimirTypeReflect returns a valid integration type from a reflect.Type. Can be type of ConfigReceiver fields, e.g EmailConfigs or type a particular configuration

func IntegrationTypeFromString

func IntegrationTypeFromString(s string) (schema.IntegrationType, error)

IntegrationTypeFromString returns a valid integration type from string. If string represents an alias, the original type is returned.

func IsAliasType

func IsAliasType(integrationType schema.IntegrationType) bool

IsAliasType returns true if the integration type is an alias.

func IsKnownIntegrationType

func IsKnownIntegrationType(integrationType schema.IntegrationType) bool

IsKnownIntegrationType returns true if the integration type is known.

func MergeSettings

func MergeSettings(a []byte, b []byte) ([]byte, error)

func NoopDecode

func NoopDecode(secrets map[string]string) (map[string][]byte, error)

NoopDecode is a DecodeSecretsFn that converts a map[string]string into a map[string][]byte without decoding it.

func NoopDecrypt

func NoopDecrypt(_ context.Context, sjd map[string][]byte, key string, fallback string) string

NoopDecrypt is a GetDecryptedValueFn that returns a value without decrypting it.

func OriginalTypeForAlias

func OriginalTypeForAlias(integrationType schema.IntegrationType) (schema.IntegrationType, bool)

OriginalTypeForAlias returns the original type for an alias. Returns true if argument is an original type

func PostableAPITemplateToTemplateDefinition

func PostableAPITemplateToTemplateDefinition(t definition.PostableApiTemplate) templates.TemplateDefinition

PostableAPITemplateToTemplateDefinition converts a definition.PostableApiTemplate to a templates.TemplateDefinition

func PostableAPITemplatesToTemplateDefinitions

func PostableAPITemplatesToTemplateDefinitions(ts []definition.PostableApiTemplate) []templates.TemplateDefinition

func ProcessIntegrationError

func ProcessIntegrationError(config *models.IntegrationConfig, err error) error

func TestIntegration

func TestIntegration(ctx context.Context,
	receiverName string,
	integrationConfig models.IntegrationConfig,
	testAlert models.TestReceiversConfigAlertParams,
	buildIntegrationsFunc func(*APIReceiver, TemplatesProvider) ([]*nfstatus.Integration, error),
	tmplProvider TemplatesProvider,
) (models.IntegrationStatus, error)

func TestNotifier

func TestNotifier(ctx context.Context, notifier *nfstatus.Integration, testAlert types.Alert, now time.Time) error

Types

type APIReceiver

type APIReceiver struct {
	ConfigReceiver        `yaml:",inline"`
	models.ReceiverConfig `yaml:",inline"`
}

func PostableAPIReceiverToAPIReceiver

func PostableAPIReceiverToAPIReceiver(r *definition.PostableApiReceiver) *APIReceiver

func PostableAPIReceiversToAPIReceivers

func PostableAPIReceiversToAPIReceivers(r []*definition.PostableApiReceiver) []*APIReceiver

type Alert

type Alert = types.Alert

type AlertGroup

type AlertGroup = amv2.AlertGroup

type AlertGroups

type AlertGroups = amv2.AlertGroups

type AlertValidationError

type AlertValidationError struct {
	Alerts amv2.PostableAlerts
	Errors []error // Errors[i] refers to Alerts[i].
}

AlertValidationError is the error capturing the validation errors faced on the alerts.

func PostableAlertsToAlertmanagerAlerts

func PostableAlertsToAlertmanagerAlerts(postableAlerts amv2.PostableAlerts, now time.Time) ([]*types.Alert, *AlertValidationError)

PostableAlertsToAlertmanagerAlerts converts the PostableAlerts to a slice of *types.Alert. It sets `StartsAt` and `EndsAt`, ignores empty and namespace UID labels, and captures validation errors for each skipped alert.

func (AlertValidationError) Error

func (e AlertValidationError) Error() string

type ClusterPeer

type ClusterPeer interface {
	AddState(string, cluster.State, prometheus.Registerer, ...cluster.ChannelOption) cluster.ClusterChannel
	Position() int
	WaitReady(context.Context) error
}

type ConfigFingerprint

type ConfigFingerprint struct {
	Overall uint64

	RoutingTree       uint64
	InhibitRules      uint64
	MuteTimeIntervals uint64
	TimeIntervals     uint64
	Templates         uint64
	Receivers         uint64
	Limits            uint64
}

ConfigFingerprint is a fingerprint of the configuration. It is used to detect changes.

func CalculateConfigFingerprint

func CalculateConfigFingerprint(cfg NotificationsConfiguration) ConfigFingerprint

CalculateConfigFingerprint calculates the fingerprint of the overall configuration and each of its fields.

func (ConfigFingerprint) String

func (f ConfigFingerprint) String() string

type ConfigReceiver

type ConfigReceiver = definition.Receiver

type DecodeSecretsFn

type DecodeSecretsFn func(secrets map[string]string) (map[string][]byte, error)

DecodeSecretsFn is a function used to decode a map of secrets before creating a receiver.

type DispatchTimer

type DispatchTimer int

DispatchTimer represents the dispatch timer behavior.

const (
	// DispatchTimerDefault represents the default dispatch timer behavior (no sync).
	DispatchTimerDefault DispatchTimer = iota
	// DispatchTimerSync represents synchronized dispatch timer (using flush log).
	DispatchTimerSync
)

func (*DispatchTimer) FromString

func (t *DispatchTimer) FromString(s string)

FromString sets the DispatchTimer based on the provided string.

func (DispatchTimer) String

func (t DispatchTimer) String() string

String returns the string representation of the DispatchTimer.

type DispatcherLimits

type DispatcherLimits = dispatch.Limits

type DynamicLimits

type DynamicLimits struct {
	Dispatcher DispatcherLimits
	Templates  templates.Limits
}

type FakeConfig

type FakeConfig struct {
}

func (*FakeConfig) DispatcherLimits

func (f *FakeConfig) DispatcherLimits() DispatcherLimits

func (*FakeConfig) Hash

func (f *FakeConfig) Hash() [16]byte

func (*FakeConfig) InhibitRules

func (f *FakeConfig) InhibitRules() []*InhibitRule

func (*FakeConfig) MuteTimeIntervals

func (f *FakeConfig) MuteTimeIntervals() []MuteTimeInterval

func (*FakeConfig) Raw

func (f *FakeConfig) Raw() []byte

func (*FakeConfig) ReceiverIntegrations

func (f *FakeConfig) ReceiverIntegrations() (map[string][]Integration, error)

func (*FakeConfig) RoutingTree

func (f *FakeConfig) RoutingTree() *Route

func (*FakeConfig) Templates

func (f *FakeConfig) Templates() *templates.Template

type GetDecryptedValueFn

type GetDecryptedValueFn func(ctx context.Context, sjd map[string][]byte, key string, fallback string) string

GetDecryptedValueFn is a function that returns the decrypted value of the given key. If the key is not present, then it returns the fallback value.

type GettableAlert

type GettableAlert = amv2.GettableAlert

type GettableAlerts

type GettableAlerts = amv2.GettableAlerts

type GettableSilence

type GettableSilence = amv2.GettableSilence

type GettableSilences

type GettableSilences = amv2.GettableSilences

type GrafanaAlertmanager

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

func NewGrafanaAlertmanager

func NewGrafanaAlertmanager(opts GrafanaAlertmanagerOpts) (*GrafanaAlertmanager, error)

NewGrafanaAlertmanager creates a new Grafana-specific Alertmanager.

func (*GrafanaAlertmanager) AppliedConfig

func (am *GrafanaAlertmanager) AppliedConfig() *NotificationsConfiguration

AppliedConfig returns the current running configuration. It is not safe to call without a lock.

func (*GrafanaAlertmanager) ApplyConfig

func (am *GrafanaAlertmanager) ApplyConfig(cfg NotificationsConfiguration) (err error)

ApplyConfig applies a new configuration by re-initializing all components using the configuration provided. It is not safe to call concurrently.

func (*GrafanaAlertmanager) ConfigHash

func (am *GrafanaAlertmanager) ConfigHash() ConfigFingerprint

ConfigHash returns the hash of the current running configuration. It is not safe to call without a lock.

func (*GrafanaAlertmanager) CreateSilence

func (am *GrafanaAlertmanager) CreateSilence(ps *PostableSilence) (string, error)

CreateSilence persists the provided silence and returns the silence ID if successful.

func (*GrafanaAlertmanager) DeleteSilence

func (am *GrafanaAlertmanager) DeleteSilence(silenceID string) error

DeleteSilence looks for and expires the silence by the provided silenceID. It returns ErrSilenceNotFound if the silence is not present.

func (*GrafanaAlertmanager) ExternalURL

func (am *GrafanaAlertmanager) ExternalURL() string

func (*GrafanaAlertmanager) GetAlertGroups

func (am *GrafanaAlertmanager) GetAlertGroups(active, silenced, inhibited bool, filter []string, receivers string) (AlertGroups, error)

func (*GrafanaAlertmanager) GetAlerts

func (am *GrafanaAlertmanager) GetAlerts(active, silenced, inhibited bool, filter []string, receivers string) (GettableAlerts, error)

func (*GrafanaAlertmanager) GetReceiversStatus

func (am *GrafanaAlertmanager) GetReceiversStatus() []models.ReceiverStatus

GetReceiversStatus returns the status of receivers configured as part of the current configuration. It is safe to call concurrently.

func (*GrafanaAlertmanager) GetSilence

func (am *GrafanaAlertmanager) GetSilence(silenceID string) (GettableSilence, error)

GetSilence retrieves a silence by the provided silenceID. It returns ErrSilenceNotFound if the silence is not present.

func (*GrafanaAlertmanager) GetTemplate

func (am *GrafanaAlertmanager) GetTemplate(kind templates.Kind) (*templates.Template, error)

func (*GrafanaAlertmanager) ListSilences

func (am *GrafanaAlertmanager) ListSilences(filter []string) (GettableSilences, error)

ListSilences retrieves a list of stored silences. It supports a set of labels as filters.

func (*GrafanaAlertmanager) MergeFlushLog

func (am *GrafanaAlertmanager) MergeFlushLog(flushLog []byte) error

func (*GrafanaAlertmanager) MergeNflog

func (am *GrafanaAlertmanager) MergeNflog(nflog []byte) error

func (*GrafanaAlertmanager) MergeSilences

func (am *GrafanaAlertmanager) MergeSilences(sil []byte) error

func (*GrafanaAlertmanager) PutAlerts

func (am *GrafanaAlertmanager) PutAlerts(postableAlerts amv2.PostableAlerts) error

PutAlerts receives the alerts and then sends them through the corresponding route based on whenever the alert has a receiver embedded or not

func (*GrafanaAlertmanager) Ready

func (am *GrafanaAlertmanager) Ready() bool

func (*GrafanaAlertmanager) SilenceState

func (am *GrafanaAlertmanager) SilenceState() (SilenceState, error)

func (*GrafanaAlertmanager) StopAndWait

func (am *GrafanaAlertmanager) StopAndWait()

func (*GrafanaAlertmanager) TenantID

func (am *GrafanaAlertmanager) TenantID() int64

func (*GrafanaAlertmanager) TestIntegration

func (am *GrafanaAlertmanager) TestIntegration(
	ctx context.Context,
	receiverName string,
	integrationConfig models.IntegrationConfig,
	alert models.TestReceiversConfigAlertParams,
) (models.IntegrationStatus, error)

func (*GrafanaAlertmanager) TestReceivers

func (*GrafanaAlertmanager) TestTemplate

TestTemplate tests the given template string against the given alerts. Existing templates are used to provide context for the test. If an existing template of the same filename as the one being tested is found, it will not be used as context.

func (*GrafanaAlertmanager) UpsertSilence

func (am *GrafanaAlertmanager) UpsertSilence(ps *PostableSilence) (string, error)

UpsertSilence allows for the creation of a silence with a pre-set ID.

func (*GrafanaAlertmanager) WithLock

func (am *GrafanaAlertmanager) WithLock(fn func())

func (*GrafanaAlertmanager) WithReadLock

func (am *GrafanaAlertmanager) WithReadLock(fn func())

type GrafanaAlertmanagerMetrics

type GrafanaAlertmanagerMetrics struct {
	Registerer prometheus.Registerer
	*metrics.Alerts
	// contains filtered or unexported fields
}

func NewGrafanaAlertmanagerMetrics

func NewGrafanaAlertmanagerMetrics(r prometheus.Registerer, l log.Logger) *GrafanaAlertmanagerMetrics

NewGrafanaAlertmanagerMetrics creates a set of metrics for the Alertmanager.

type GrafanaAlertmanagerOpts

type GrafanaAlertmanagerOpts struct {
	ExternalURL        string
	AlertStoreCallback mem.AlertStoreCallback
	PeerTimeout        time.Duration

	Silences MaintenanceOptions
	Nflog    MaintenanceOptions
	FlushLog MaintenanceOptions

	Limits Limits

	EmailSender   receivers.EmailSender
	ImageProvider images.Provider
	Decrypter     GetDecryptedValueFn

	Version   string
	TenantKey string
	TenantID  int64

	Peer    ClusterPeer
	Logger  log.Logger
	Metrics *GrafanaAlertmanagerMetrics

	NotificationHistorian nfstatus.NotificationHistorian

	DispatchTimer DispatchTimer
}

func (*GrafanaAlertmanagerOpts) Validate

func (c *GrafanaAlertmanagerOpts) Validate() error

type GrafanaReceiverConfig

type GrafanaReceiverConfig struct {
	Name                string
	AlertmanagerConfigs []*NotifierConfig[alertmanager.Config]
	DingdingConfigs     []*NotifierConfig[dingding.Config]
	DiscordConfigs      []*NotifierConfig[discord.Config]
	EmailConfigs        []*NotifierConfig[email.Config]
	GooglechatConfigs   []*NotifierConfig[googlechat.Config]
	JiraConfigs         []*NotifierConfig[jira.Config]
	KafkaConfigs        []*NotifierConfig[kafka.Config]
	LineConfigs         []*NotifierConfig[line.Config]
	OpsgenieConfigs     []*NotifierConfig[opsgenie.Config]
	MqttConfigs         []*NotifierConfig[mqtt.Config]
	PagerdutyConfigs    []*NotifierConfig[pagerduty.Config]
	OnCallConfigs       []*NotifierConfig[oncall.Config]
	PushoverConfigs     []*NotifierConfig[pushover.Config]
	SensugoConfigs      []*NotifierConfig[sensugo.Config]
	SlackConfigs        []*NotifierConfig[slack.Config]
	SNSConfigs          []*NotifierConfig[sns.Config]
	TeamsConfigs        []*NotifierConfig[teams.Config]
	TelegramConfigs     []*NotifierConfig[telegram.Config]
	ThreemaConfigs      []*NotifierConfig[threema.Config]
	VictoropsConfigs    []*NotifierConfig[victorops.Config]
	WebhookConfigs      []*NotifierConfig[webhook.Config]
	WecomConfigs        []*NotifierConfig[wecom.Config]
	WebexConfigs        []*NotifierConfig[webex.Config]
}

GrafanaReceiverConfig represents a parsed and validated APIReceiver

func BuildReceiverConfiguration

func BuildReceiverConfiguration(ctx context.Context, api *APIReceiver, decode DecodeSecretsFn, decrypt GetDecryptedValueFn) (GrafanaReceiverConfig, error)

BuildReceiverConfiguration parses, decrypts and validates the APIReceiver.

type InhibitRule

type InhibitRule = config.InhibitRule

type Integration

type Integration = nfstatus.Integration

func BuildGrafanaReceiverIntegrations

func BuildGrafanaReceiverIntegrations(
	receiver GrafanaReceiverConfig,
	tmpl *templates.Template,
	img images.Provider,
	logger log.Logger,
	emailSender receivers.EmailSender,
	wrapNotifier WrapNotifierFunc,
	orgID int64,
	version string,
	notificationHistorian nfstatus.NotificationHistorian,
	httpClientOptions ...http.ClientOption,
) ([]*Integration, error)

BuildGrafanaReceiverIntegrations creates integrations for each configured notification channel in GrafanaReceiverConfig. It returns a slice of Integration objects, one for each notification channel, along with any errors that occurred.

func BuildReceiverIntegrations

func BuildReceiverIntegrations(
	tenantID int64,
	receiver *APIReceiver,
	tmpls TemplatesProvider,
	images images.Provider,
	decryptFn GetDecryptedValueFn,
	decodeFn DecodeSecretsFn,
	emailSender receivers.EmailSender,
	httpClientOptions []http.ClientOption,
	wrapNotifierFunc WrapNotifierFunc,
	version string,
	logger log.Logger,
	notificationHistorian nfstatus.NotificationHistorian,
) ([]*Integration, error)

BuildReceiverIntegrations builds integrations for the provided API receiver and returns them. It supports both Prometheus and Grafana integrations and ensures that both of them use only templates dedicated for the kind.

type IntegrationTimeoutError

type IntegrationTimeoutError struct {
	Integration *models.IntegrationConfig
	Err         error
}

func (IntegrationTimeoutError) Error

func (e IntegrationTimeoutError) Error() string

type IntegrationValidationError

type IntegrationValidationError struct {
	Err         error
	Integration *models.IntegrationConfig
}

func (IntegrationValidationError) Error

func (IntegrationValidationError) Unwrap

func (e IntegrationValidationError) Unwrap() error

type Limits

type Limits struct {
	MaxSilences         int
	MaxSilenceSizeBytes int
}

type MaintenanceOptions

type MaintenanceOptions interface {
	// InitialState returns the initial snapshot of the artefacts under maintenance. This will be loaded when the Alertmanager starts.
	InitialState() string
	// Retention represents for how long should we keep the artefacts under maintenance.
	Retention() time.Duration
	// MaintenanceFrequency represents how often should we execute the maintenance.
	MaintenanceFrequency() time.Duration
	// MaintenanceFunc returns the function to execute as part of the maintenance process. This will usually take a snaphot of the artefacts under maintenance.
	// It returns the size of the state in bytes or an error if the maintenance fails.
	MaintenanceFunc(state State) (int64, error)
}

MaintenanceOptions represent the configuration options available for executing maintenance of Silences and the Notification log that the Alertmanager uses.

type MimirIntegrationConfig

type MimirIntegrationConfig struct {
	Schema schema.IntegrationSchemaVersion
	Config any
}

func ConfigReceiverToMimirIntegrations

func ConfigReceiverToMimirIntegrations(receiver ConfigReceiver) ([]MimirIntegrationConfig, error)

ConfigReceiverToMimirIntegrations converts a ConfigReceiver to a list of MimirIntegrationConfig

func (MimirIntegrationConfig) ConfigJSON

func (c MimirIntegrationConfig) ConfigJSON() ([]byte, error)

ConfigJSON returns the JSON representation of the integration config with non-masked secrets.

func (MimirIntegrationConfig) ConfigMap

func (c MimirIntegrationConfig) ConfigMap() (map[string]any, error)

type MuteTimeInterval

type MuteTimeInterval = config.MuteTimeInterval

type NilChannel

type NilChannel struct{}

func (*NilChannel) Broadcast

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

func (*NilChannel) ReliableDelivery

func (c *NilChannel) ReliableDelivery([]byte) bool

type NilPeer

type NilPeer struct{}

NilPeer and NilChannel implements the Alertmanager clustering interface.

func (*NilPeer) Position

func (p *NilPeer) Position() int

func (*NilPeer) WaitReady

func (p *NilPeer) WaitReady(context.Context) error

type NotificationsConfiguration

type NotificationsConfiguration struct {
	RoutingTree       *Route
	InhibitRules      []InhibitRule
	MuteTimeIntervals []MuteTimeInterval
	TimeIntervals     []TimeInterval
	Templates         []templates.TemplateDefinition
	Receivers         []*APIReceiver

	Limits DynamicLimits
}

type Notifier

type Notifier = notify.Notifier

type NotifierConfig

type NotifierConfig[T interface{}] struct {
	receivers.Metadata
	Settings         T
	HTTPClientConfig *http.HTTPClientConfig
}

NotifierConfig represents parsed IntegrationConfig.

type NotifyReceiver

type NotifyReceiver = nfstatus.Receiver

type PostableAlert

type PostableAlert = amv2.PostableAlert

type PostableAlerts

type PostableAlerts = amv2.PostableAlerts

type PostableSilence

type PostableSilence = amv2.PostableSilence

type Receiver

type Receiver = amv2.Receiver

type Route

type Route = definition.Route

type Silence

type Silence = amv2.Silence

type SilenceState

type SilenceState map[string]*silencepb.MeshSilence

SilenceState copied from state in prometheus-alertmanager/silence/silence.go.

func DecodeState

func DecodeState(r io.Reader) (SilenceState, error)

DecodeState copied from decodeState in prometheus-alertmanager/silence/silence.go.

func (SilenceState) MarshalBinary

func (s SilenceState) MarshalBinary() ([]byte, error)

type State

type State interface {
	MarshalBinary() ([]byte, error)
}

State represents any of the two 'states' of the alertmanager. Notification log or Silences. MarshalBinary returns the binary representation of this internal state based on the protobuf.

type TemplateErrorKind

type TemplateErrorKind string
const (
	InvalidTemplate TemplateErrorKind = "invalid_template"
	ExecutionError  TemplateErrorKind = "execution_error"
)

type TemplateScope

type TemplateScope string

TemplateScope is the scope used to interpolate the template when testing.

func (TemplateScope) Data

func (s TemplateScope) Data(data *templates.ExtendedData) any

Data returns the template data to be used with the given scope.

type TemplatesProvider

type TemplatesProvider interface {
	GetTemplate(kind templates.Kind) (*templates.Template, error)
}

type TestIntegrationConfigResult

type TestIntegrationConfigResult struct {
	Name   string `json:"name"`
	UID    string `json:"uid"`
	Status string `json:"status"`
	Error  string `json:"error"`
}

type TestReceiverResult

type TestReceiverResult struct {
	Name    string                        `json:"name"`
	Configs []TestIntegrationConfigResult `json:"configs"`
}

type TestReceiversConfigBodyParams

type TestReceiversConfigBodyParams struct {
	Alert     *models.TestReceiversConfigAlertParams `yaml:"alert,omitempty" json:"alert,omitempty"`
	Receivers []*APIReceiver                         `yaml:"receivers,omitempty" json:"receivers,omitempty"`
}

type TestReceiversResult

type TestReceiversResult struct {
	Alert     types.Alert          `json:"alert"`
	Receivers []TestReceiverResult `json:"receivers"`
	NotifedAt time.Time            `json:"notifiedAt"`
}

func TestReceivers

func TestReceivers(
	ctx context.Context,
	c TestReceiversConfigBodyParams,
	buildIntegrationsFunc func(*APIReceiver, TemplatesProvider) ([]*nfstatus.Integration, error),
	tmplProvider TemplatesProvider,
) (*TestReceiversResult, int, error)

type TestTemplatesConfigBodyParams

type TestTemplatesConfigBodyParams struct {
	// Alerts to use as data when testing the template.
	Alerts []*PostableAlert

	// Template string to test.
	Template string

	// Name of the template.
	Name string

	// Kind of template to test. Default is Grafana
	Kind templates.Kind
}

type TestTemplatesErrorResult

type TestTemplatesErrorResult struct {
	// Name of the associated template for this error. Will be empty if the Kind is "invalid_template".
	Name string `json:"name"`

	// Kind of template error that occurred.
	Kind TemplateErrorKind `json:"kind"`

	// Error cause.
	Error string `json:"error"`
}

type TestTemplatesResult

type TestTemplatesResult struct {
	// Name of the associated template definition for this result.
	Name string `json:"name"`

	// Interpolated value of the template.
	Text string `json:"text"`

	// Scope that was successfully used to interpolate the template. If the root scope "." fails, more specific
	// scopes will be tried, such as ".Alerts', or ".Alert".
	Scope TemplateScope `json:"scope"`
}

type TestTemplatesResults

type TestTemplatesResults struct {
	Results []TestTemplatesResult      `json:"results"`
	Errors  []TestTemplatesErrorResult `json:"errors"`
}

type TimeInterval

type TimeInterval = config.TimeInterval

type WrapNotifierFunc

type WrapNotifierFunc func(integrationName string, notifier nfstatus.Notifier) nfstatus.Notifier
var NoWrap WrapNotifierFunc = func(_ string, notifier nfstatus.Notifier) nfstatus.Notifier { return notifier }

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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