alert

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SilenceStatusTotal   = "total"
	SilenceStatusPartial = "partial"
)

Variables

View Source
var (
	ErrRelation = errors.New("provider id does not exist")
)

Functions

This section is empty.

Types

type Alert

type Alert struct {
	ID            uint64    `json:"id"`
	ProviderID    uint64    `json:"provider_id"`
	NamespaceID   uint64    `json:"namespace_id"`
	ResourceName  string    `json:"resource_name"`
	MetricName    string    `json:"metric_name"`
	MetricValue   string    `json:"metric_value"`
	Severity      string    `json:"severity"`
	Rule          string    `json:"rule"`
	TriggeredAt   time.Time `json:"triggered_at"`
	CreatedAt     time.Time `json:"created_at"`
	UpdatedAt     time.Time `json:"updated_at"`
	SilenceStatus string    `json:"silence_status"`

	// These fields won't be stored in the DB
	// these are additional information for notification purposes
	GroupKey     string
	Status       string
	Annotations  map[string]string
	Labels       map[string]string
	GeneratorURL string
	Fingerprint  string
}

func FromV1beta1Proto added in v0.6.7

func FromV1beta1Proto(proto *sirenv1beta1.Alert) *Alert

func (*Alert) ToV1beta1Proto added in v0.6.7

func (a *Alert) ToV1beta1Proto() *sirenv1beta1.Alert

type AlertTransformer

type AlertTransformer interface {
	TransformToAlerts(ctx context.Context, providerID uint64, namespaceID uint64, body map[string]any) ([]Alert, int, error)
}

type Filter

type Filter struct {
	ResourceName string
	ProviderID   uint64
	NamespaceID  uint64
	StartTime    int64
	EndTime      int64
	SilenceID    string
	IDs          []int64
}

type LogService

type LogService interface {
	ListAlertIDsBySilenceID(ctx context.Context, silenceID string) ([]int64, error)
}

type Repository

type Repository interface {
	Create(context.Context, Alert) (Alert, error)
	List(context.Context, Filter) ([]Alert, error)
	BulkUpdateSilence(context.Context, []int64, string) error
}

type Service

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

Service handles business logic

func NewService

func NewService(repository Repository, logService LogService, registry map[string]AlertTransformer) *Service

NewService returns repository struct

func (*Service) CreateAlerts

func (s *Service) CreateAlerts(ctx context.Context, providerType string, providerID uint64, namespaceID uint64, body map[string]any) ([]Alert, int, error)

func (*Service) List

func (s *Service) List(ctx context.Context, flt Filter) ([]Alert, error)

func (*Service) UpdateSilenceStatus

func (s *Service) UpdateSilenceStatus(ctx context.Context, alertIDs []int64, hasSilenced bool, hasNonSilenced bool) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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