alert

package
v0.0.0-...-9e50629 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	// Level defines the level of the alert
	Level Level `json:"level"`
	// Message describes the alert
	Message string `json:"message"`
	// ObjectRef defines the k8s object designated by the alert
	ObjectRef ObjectRef `json:"objectRef"`
	// Source defines the source of the alert
	Source string `json:"source"`
	// When defines when the alert has been created
	When int64 `json:"when"`
}

Alert contains the information about the alert

type KafkaConfig

type KafkaConfig struct {
	Topic   string   `yaml:"topic"`
	Brokers []string `yaml:"brokers"`
}

type Level

type Level uint8

Level defines the level of an alert, it is an enum of UNKNOWN, INFO, WARN, ERROR

const (
	Unknown Level = iota
	Info
	Warn
	Error
)

func (Level) MarshalJSON

func (l Level) MarshalJSON() ([]byte, error)

MarshalJSON marshals the enum as a quoted json string

func (Level) String

func (l Level) String() string

String returns a string representation of the Level value

func (*Level) UnmarshalJSON

func (l *Level) UnmarshalJSON(b []byte) error

UnmarshalJSON unmashals a quoted json string to the enum value

type Notifier

type Notifier interface {
	// Send sends the alert to the external system
	Send(alert Alert) error
	// Close closes the notifier
	Close() error
}

Notifier is responsible to send an alert to an external system

func NewKafkaNotifier

func NewKafkaNotifier(topic string, producer sarama.SyncProducer) Notifier

func NewLogNotifier

func NewLogNotifier(logger *zap.SugaredLogger) Notifier

NewLogNotifier returns a Notifier that generate logs using the passed logger

type ObjectRef

type ObjectRef struct {
	// Name is the name of the k8s object
	Name string `json:"name"`
	// Namespace is the namespace of the k8s object
	Namespace string `json:"namespace"`
}

ObjectRef contains the information to locate the object in k8s, namely its name and namespace

Jump to

Keyboard shortcuts

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