alerts

package
v0.0.0-...-2b4ff5e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandler

func AddHandler(token string, storer Storer) echo.HandlerFunc

AddHandler returns an add handler

func DeleteHandler

func DeleteHandler(token string, storer Storer) echo.HandlerFunc

DeleteHandler returns a delete handler

func StoreHandler

func StoreHandler(token string, storer Storer) echo.HandlerFunc

StoreHandler returns an Echo handler for storing payloads

Types

type Alert

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

Alert describes a notification alert

type PGPayload

type PGPayload struct {
	ID        int64          `db:"id"`
	CreatedAt time.Time      `db:"created_at"`
	Payload   types.JSONText `db:"payload"`
}

PGPayload is an entry in the alerts table that wraps Payload

type PGStorer

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

PGStorer is an PostgreSQL implementation of the Storer interface

func NewPGStorer

func NewPGStorer() (*PGStorer, error)

NewPGStorer retruns a psql storer

func (*PGStorer) Init

func (p *PGStorer) Init() error

Init initializes the database

func (*PGStorer) Remove

func (p *PGStorer) Remove(payload Payload) error

Remove removes all instances of alertName

func (*PGStorer) Store

func (p *PGStorer) Store(payload Payload) error

Store stores a payload in the psql DB

type Payload

type Payload struct {
	Receiver          string            `json:"receiver,omitempty"`
	Status            string            `json:"status,omitempty"`
	Alerts            []Alert           `json:"alerts,omitempty"`
	GroupLabels       map[string]string `json:"groupLabels,omitempty"`
	CommonLabels      map[string]string `json:"commonLabels,omitempty"`
	CommonAnnotations map[string]string `json:"commonAnnotations,omitempty"`
	ExternalURL       string            `json:"externalURL,omitempty"`
	Version           string            `json:"version,omitempty"`
	GroupKey          string            `json:"groupKey,omitempty"`
	AlertName         string            `json:"alertName,omitempty"`
}

Payload describes the webhook payload as send by the notification service

type Storer

type Storer interface {
	Init() error
	Store(payload Payload) error
	Remove(payload Payload) error
}

Storer interface for payloads

Jump to

Keyboard shortcuts

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