internal

package
v0.0.0-...-5f33b41 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MatchEvent   = Event("match")
	SuccessEvent = Event("success")
	FailureEvent = Event("failure")
)

Constants used to signal the different kind of events

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Status       string            `json:"status"`
	Labels       map[string]string `json:"labels"`
	Annotations  map[string]string `json:"annotations"`
	StartsAt     time.Time         `json:"startsAt"`
	EndsAt       time.Time         `json:"endsAt"`
	GeneratorURL string            `json:"generatorURL"`
}

Alert holds one alert for notification templates.

type AlertGroup

type AlertGroup struct {
	Version  string `json:"version"`
	GroupKey string `json:"groupKey"`

	Receiver string `json:"receiver"`
	Status   string `json:"status"`
	Alerts   Alerts `json:"alerts"`

	GroupLabels       map[string]string `json:"groupLabels"`
	CommonLabels      map[string]string `json:"commonLabels"`
	CommonAnnotations map[string]string `json:"commonAnnotations"`

	ExternalURL string `json:"externalURL"`
}

AlertGroup is the data read from a webhook call

type Alerts

type Alerts []Alert

Alerts is a slice of Alert

type Configuration

type Configuration struct {
	Matchers        []MatcherConfiguration `yaml:"matchers,omitempty"`
	DefaultTemplate *MessageTemplate       `yaml:"default_template,omitempty"`
}

Configuration represents the configuration of the alert matchers

type Event

type Event string

Event is an extension of a string used to map the different colors of the events

func (Event) Color

func (e Event) Color() string

Color returns the color given the kind of event it is

type MatcherConfiguration

type MatcherConfiguration struct {
	Name        string            `yaml:"name"`
	Labels      map[string]string `yaml:"labels"`
	Annotations map[string]string `yaml:"annotations"`
	Command     string            `yaml:"command"`
	Arguments   []string          `yaml:"args"`
	Template    *MessageTemplate  `yaml:"template,omitempty"`
	Timeout     int               `yaml:"timeout_seconds"`
}

MatcherConfiguration provides configuration to match alerts and map them to a command with arguments

type MessageTemplate

type MessageTemplate struct {
	OnMatch   string `yaml:"on_match"`
	OnSuccess string `yaml:"on_success"`
	OnFailure string `yaml:"on_failure"`
}

MessageTemplate is the message to send when the match is successful

func (MessageTemplate) GetMessage

func (m MessageTemplate) GetMessage(event Event) string

GetMessage returns the template according to the event type

type Messenger

type Messenger interface {
	Send(Event, string) error
}

Messenger represents an object capable of sending a message to somewhere

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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