alert

package
v0.0.0-...-efbd42f Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	Message     string
	Alias       string
	Description string
	Actions     []string
	Tags        []string
	Entity      string
	Priority    Priority
	Responder   []Responder
	VisibleTo   []Responder
	// contains filtered or unexported fields
}

Alert is the alert struct.

type AlertClient

type AlertClient interface {
	CreateAlert(key string, alertCtx AlertContext) (Alert, error)
	Send(ctx context.Context, alert Alert) error
	CreateAndSend(ctx context.Context, key string, alertCtx AlertContext) error
}

type AlertConfig

type AlertConfig struct {
	Environment string
	ApiKey      string
	Enabled     bool
}

type AlertContext

type AlertContext struct {
	Details map[string]string
	Error   error
	Note    string
}

AlertContext contains the alert execution context.

type DummyClient

type DummyClient struct{}

DummyClient is a dummy alert client.

func NewDummyClient

func NewDummyClient() *DummyClient

NewDummyClient creates a new dummy alert client.

func (*DummyClient) CreateAlert

func (d *DummyClient) CreateAlert(key string, alertCtx AlertContext) (Alert, error)

NewDummyClient creates a new dummy alert client.

func (*DummyClient) CreateAndSend

func (d *DummyClient) CreateAndSend(ctx context.Context, key string, alertCtx AlertContext) error

CreateAndSend creates an alert by key and alert context and sends it to opsgenie.

func (*DummyClient) Send

func (d *DummyClient) Send(ctx context.Context, alert Alert) error

Send sends an alert to opsgenie.

type OpsgenieClient

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

OpsgenieClient is the alert client.

func NewAlertService

func NewAlertService(cfg AlertConfig, registerAlertsFunc RegisterAlertsFunc) (*OpsgenieClient, error)

NewAlertService creates a new alert service

func (*OpsgenieClient) CreateAlert

func (s *OpsgenieClient) CreateAlert(key string, alertCtx AlertContext) (Alert, error)

CreateAlert creates an alert by key and alert context. The key is the alert name, and with it we can get the alert from the registerd alerts. The alert context contains the alert execution data

func (*OpsgenieClient) CreateAndSend

func (s *OpsgenieClient) CreateAndSend(ctx context.Context, key string, alertCtx AlertContext) error

CreateAndSend creates an alert by key and alert context and sends it to opsgenie.

func (*OpsgenieClient) Send

func (s *OpsgenieClient) Send(ctx context.Context, alert Alert) error

Send sends an alert to opsgenie.

type Priority

type Priority string

Priority is the alert priority.

const (
	CRITICAL      Priority = "CRITICAL"
	HIGH          Priority = "HIGH"
	MODERATE      Priority = "MODERATE"
	LOW           Priority = "LOW"
	INFORMATIONAL Priority = "INFORMATIONAL"
)

type RegisterAlertsFunc

type RegisterAlertsFunc func(cfg AlertConfig) map[string]Alert

RegisterAlertsFunc is the function that loads the alerts from the corresponding component.

type Responder

type Responder struct {
	Id       string
	Type     string
	Name     string
	Username string
}

Respoder struct to define alert routing notifications.

Jump to

Keyboard shortcuts

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