alerts

package
v0.0.0-...-8fead6e Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2019 License: GPL-3.0 Imports: 11 Imported by: 3

Documentation

Overview

Package alerts has functions and data types for storing alert information and calculating similar alerts.

Index

Constants

View Source
const TimeFormat = time.RFC3339

TimeFormat is the time format of alert boundaries

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Annotations  map[string]string `json:"annotations,omitempty"`
	StartsAt     string            `json:"startsAt,omitempty"`
	EndsAt       string            `json:"endsAt,omitempty"`
	GeneratorURL string            `json:"generatorURL,omitempty"`
	Labels       map[string]string `json:"labels"`
	Status       string            `json:"status,omitempty"`
	Related      map[string]uint   `json:"related,omitempty"`
}

Alert stores the necessary data of one alert.

func NewAlert

func NewAlert() Alert

NewAlert constructs a new Alert object.

func (*Alert) Hash

func (a *Alert) Hash() string

Hash calculates the alert's hash. Used to identify identical alerts.

type AlertSource

type AlertSource interface {
	GetAlertsFromTo(StartsAt, EndsAt time.Time) ([]Alert, error)
}

AlertSource is an interface for all alerts sources.

type ElasticSearchSource

type ElasticSearchSource struct {
	AlertSource
	// contains filtered or unexported fields
}

ElasticSearchSource represents ElasticSearch as a source for alerts.

func NewElasticSearchSource

func NewElasticSearchSource(index string, client *elastic.Client, logger *zap.Logger) (ElasticSearchSource, error)

NewElasticSearchSource returns a new ElasticSearchSource.

func (ElasticSearchSource) GetAlertsFromTo

func (es ElasticSearchSource) GetAlertsFromTo(from, to time.Time) (ret []Alert, err error)

GetAlertsFromTo retrieves the alerts between specified boundaries.

type State

type State struct {
	Firing      []string
	Alerts      map[string]Alert
	LastUpdated time.Time
	// contains filtered or unexported fields
}

State is the current state of the alerts parser.

func NewState

func NewState() State

NewState initializes a new State variable.

func (*State) AddAlert

func (s *State) AddAlert(a Alert) error

AddAlert adds alert to the state and parses it.

func (*State) GetLastUpdated

func (s *State) GetLastUpdated() time.Time

GetLastUpdated gets the time when State was last updated.

Jump to

Keyboard shortcuts

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