types

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventStatusCritical = "Critical"
	EventStatusWarning  = "Warning"
	EventStatusInfo     = "Info"
	EventStatusOk       = "Ok"

	DescFormatText     = ""
	DescFormatMarkdown = "markdown"

	// AttrCurrentValue is the standard Attrs key for the primary metric value
	// that triggered an alert. Plugins should set this so that diagnosis records
	// and AI prompts can display it consistently.
	AttrCurrentValue = "current_value"

	// AttrThresholdDesc is a human-readable description of the threshold(s)
	// that define when this check fires. Plugins format it freely, e.g.
	// "Warning ≥ 80.0%, Critical ≥ 95.0%" or "Critical: state ≠ active".
	AttrThresholdDesc = "threshold_desc"
)

Variables

This section is empty.

Functions

func EvaluateGeThreshold

func EvaluateGeThreshold(value, warnGe, criticalGe float64) string

EvaluateGeThreshold returns the event status for a "greater-than-or-equal" threshold pair. A threshold value of 0 means "not configured / disabled".

func EventStatusValid

func EventStatusValid(status string) bool

Types

type Event

type Event struct {
	EventTime         int64             `json:"event_time"`
	EventStatus       string            `json:"event_status"`
	AlertKey          string            `json:"alert_key"`
	Labels            map[string]string `json:"labels"`
	Attrs             map[string]string `json:"attrs,omitempty"`
	Description       string            `json:"description"`
	DescriptionFormat string            `json:"description_format,omitempty"`

	// for internal use
	FirstFireTime int64 `json:"-"`
	NotifyCount   int64 `json:"-"`
	LastSent      int64 `json:"-"`
}

func BuildEvent

func BuildEvent(labelMaps ...map[string]string) *Event

func (*Event) SetAttrs

func (e *Event) SetAttrs(attrs map[string]string) *Event

func (*Event) SetCurrentValue

func (e *Event) SetCurrentValue(v string) *Event

func (*Event) SetDescription

func (e *Event) SetDescription(desc string) *Event

func (*Event) SetEventStatus

func (e *Event) SetEventStatus(status string) *Event

func (*Event) SetEventTime

func (e *Event) SetEventTime(t int64) *Event

Jump to

Keyboard shortcuts

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