notifier

package
v1.35.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitTemplateFunc

func InitTemplateFunc(externalURL *url.URL)

InitTemplateFunc returns template helper functions

func ValidateTemplates added in v1.35.0

func ValidateTemplates(annotations map[string]string) error

ValidateTemplates validate annotations for possible template error, uses empty data for template population

Types

type Alert

type Alert struct {
	Group       string
	Name        string
	Labels      map[string]string
	Annotations map[string]string
	State       AlertState

	Start time.Time
	End   time.Time
	Value float64
	ID    uint64
}

Alert the triggered alert TODO: Looks like alert name isn't unique

func (*Alert) ExecTemplate

func (a *Alert) ExecTemplate(annotations map[string]string) (map[string]string, error)

ExecTemplate executes the Alert template for give map of annotations.

type AlertManager

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

AlertManager represents integration provider with Prometheus alert manager https://github.com/prometheus/alertmanager

func NewAlertManager

func NewAlertManager(alertManagerURL string, fn AlertURLGenerator, c *http.Client) *AlertManager

NewAlertManager is a constructor for AlertManager

func (*AlertManager) Send

func (am *AlertManager) Send(alerts []Alert) error

Send an alert or resolve message

type AlertState

type AlertState int

AlertState type indicates the Alert state

const (
	// StateInactive is the state of an alert that is neither firing nor pending.
	StateInactive AlertState = iota
	// StatePending is the state of an alert that has been active for less than
	// the configured threshold duration.
	StatePending
	// StateFiring is the state of an alert that has been active for longer than
	// the configured threshold duration.
	StateFiring
)

func (AlertState) String

func (as AlertState) String() string

String stringer for AlertState

type AlertURLGenerator

type AlertURLGenerator func(group, id string) string

AlertURLGenerator returns URL to single alert by given name

type Notifier

type Notifier interface {
	Send(alerts []Alert) error
}

Notifier is common interface for alert manager provider

type Time

type Time int64

Time is the number of milliseconds since the epoch (1970-01-01 00:00 UTC) excluding leap seconds.

func TimeFromUnixNano

func TimeFromUnixNano(t int64) Time

TimeFromUnixNano returns the Time equivalent to the Unix Time t provided in nanoseconds.

func (Time) Time

func (t Time) Time() time.Time

Time returns the time.Time representation of t.

Jump to

Keyboard shortcuts

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