alerts

package
v0.0.0-...-ebc7474 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: MIT Imports: 9 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 {
	AlertID         string
	Attempts        int
	Cluster         string
	Created         time.Time
	Dispatched      time.Time
	LogSource       string
	LogType         string
	MergeByKeys     []string
	MergeWindow     time.Duration
	Dispatchers     []string
	OutputsSent     []string
	Formatters      []string
	Record          shared.Record
	RuleDescription string
	RuleName        string
	RuleID          string
	SourceEntity    string
	SourceService   string
	Staged          bool
}

Alert struct encapsulates a single alert and handles serialization

func Merge

func Merge(alerts []*Alert) (*Alert, error)

Merge merges multiple alerts into a new merged alert

func NewAlert

func NewAlert(ruleName string, record shared.Record, dispatchers []string, opts ...AlertOption) (*Alert, error)

NewAlert creates a new Alert

func (*Alert) CanMerge

func (a *Alert) CanMerge(other *Alert) bool

CanMerge checks if two alerts can be merged together

func (*Alert) FullString

func (a *Alert) FullString() string

FullString returns a detailed representation of the alert

func (*Alert) Less

func (a *Alert) Less(other *Alert) bool

Less compares alerts by their creation time

func (*Alert) MergeEnabled

func (a *Alert) MergeEnabled() bool

func (*Alert) OutputDict

func (a *Alert) OutputDict() (map[string]any, error)

OutputDict converts the alert to a dictionary ready to send to an output

func (*Alert) RecordKey

func (a *Alert) RecordKey() map[string]any

func (*Alert) RemainingOutputs

func (a *Alert) RemainingOutputs(requiredOutputs []string) []string

func (*Alert) String

func (a *Alert) String() string

String returns a simple representation of the alert

type AlertError

type AlertError struct {
	Message string
}

AlertCreationError custom error for alert creation

func (*AlertError) Error

func (e *AlertError) Error() string

type AlertOption

type AlertOption func(*Alert)

AlertOption defines the functional option type

func Attempts

func Attempts(attempts int) AlertOption

Attempts sets the number of attempts for the alert

func Cluster

func Cluster(cluster string) AlertOption

Cluster sets the cluster for the alert

func Created

func Created(created time.Time) AlertOption

Created sets the creation time for the alert

func Dispatched

func Dispatched(dispatched time.Time) AlertOption

Dispatched sets the dispatched time for the alert

func Formatters

func Formatters(formatters []string) AlertOption

Formatters sets the formatters for the alert

func LogSource

func LogSource(logSource string) AlertOption

LogSource sets the log source for the alert

func LogType

func LogType(logType string) AlertOption

LogType sets the log type for the alert

func MergeByKeys

func MergeByKeys(mergeByKeys []string) AlertOption

MergeByKeys sets the merge by keys for the alert

func MergeWindow

func MergeWindow(mergeWindow time.Duration) AlertOption

MergeWindow sets the merge window for the alert

func OutputsSent

func OutputsSent(outputsSent []string) AlertOption

OutputsSent sets the outputs sent for the alert

func RuleDescription

func RuleDescription(ruleDescription string) AlertOption

RuleDescription sets the rule description for the alert

func SourceEntity

func SourceEntity(sourceEntity string) AlertOption

SourceEntity sets the source entity for the alert

func SourceService

func SourceService(sourceService string) AlertOption

SourceService sets the source service for the alert

func Staged

func Staged(staged bool) AlertOption

Staged sets the staged flag for the alert

Jump to

Keyboard shortcuts

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