alerting

package
v0.0.0-...-be065d1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: MIT Imports: 12 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 {
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
	State       string            `json:"state"`
	ActiveAt    *time.Time        `json:"activeAt,omitempty"`
	Value       string            `json:"value"`
}

type AlertingRule

type AlertingRule struct {
	// State can be "pending", "firing", "inactive".
	State       string            `json:"state"`
	Name        string            `json:"name"`
	Query       string            `json:"query"`
	Duration    float64           `json:"duration"`
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
	Alerts      []*Alert          `json:"alerts"`
	// Health can be "ok", "err", "unknown".
	Health         string     `json:"health"`
	LastError      string     `json:"lastError,omitempty"`
	EvaluationTime *float64   `json:"evaluationTime"`
	LastEvaluation *time.Time `json:"lastEvaluation"`
	// Type of an alertingRule is always "alerting".
	Type string `json:"type"`
}

type Error

type Error struct {
	Type   ErrorType
	Msg    string
	Detail string
}

func (*Error) Error

func (e *Error) Error() string

type ErrorType

type ErrorType string
const (
	ErrBadData     ErrorType = "bad_data"
	ErrTimeout     ErrorType = "timeout"
	ErrCanceled    ErrorType = "canceled"
	ErrExec        ErrorType = "execution"
	ErrBadResponse ErrorType = "bad_response"
	ErrServer      ErrorType = "server_error"
	ErrClient      ErrorType = "client_error"
)

type Options

type Options struct {
	Endpoint string `json:"endpoint" yaml:"endpoint"`

	// The following options are for the alerting with v2alpha1 version or higher versions
	PrometheusEndpoint       string `json:"prometheusEndpoint" yaml:"prometheusEndpoint"`
	ThanosRulerEndpoint      string `json:"thanosRulerEndpoint" yaml:"thanosRulerEndpoint"`
	ThanosRuleResourceLabels string `json:"thanosRuleResourceLabels" yaml:"thanosRuleResourceLabels"`
}

func NewAlertingOptions

func NewAlertingOptions() *Options

func (*Options) AddFlags

func (o *Options) AddFlags(fs *pflag.FlagSet, c *Options)

func (*Options) ApplyTo

func (o *Options) ApplyTo(options *Options)

func (*Options) Validate

func (o *Options) Validate() []error

type RuleClient

type RuleClient interface {
	PrometheusRules(ctx context.Context) ([]*RuleGroup, error)
	ThanosRules(ctx context.Context, matchers ...[]*labels.Matcher) ([]*RuleGroup, error)
}

func NewRuleClient

func NewRuleClient(options *Options) (RuleClient, error)

type RuleGroup

type RuleGroup struct {
	Name           string          `json:"name"`
	File           string          `json:"file"`
	Rules          []*AlertingRule `json:"rules"`
	Interval       float64         `json:"interval"`
	EvaluationTime float64         `json:"evaluationTime"`
	LastEvaluation *time.Time      `json:"lastEvaluation"`
}

Jump to

Keyboard shortcuts

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