config

package
v1.101.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashRule added in v1.37.1

func HashRule(r Rule) uint64

HashRule hashes significant Rule fields into unique hash that supposed to define Rule uniqueness

Types

type FS added in v1.88.0

type FS interface {
	// Init initializes FS.
	Init() error

	// String must return human-readable representation of FS.
	String() string

	// List returns the list of file names which will be read via Read fn
	List() ([]string, error)

	// Read returns a list of read files in form of a map
	// where key is a file name and value is a content of read file.
	// Read must be called only after the successful Init call.
	Read(files []string) (map[string][]byte, error)
}

FS represent a file system abstract for reading files.

type Group

type Group struct {
	Type       Type `yaml:"type,omitempty"`
	File       string
	Name       string              `yaml:"name"`
	Interval   *promutils.Duration `yaml:"interval,omitempty"`
	EvalOffset *promutils.Duration `yaml:"eval_offset,omitempty"`
	// EvalDelay will adjust the `time` parameter of rule evaluation requests to compensate intentional query delay from datasource.
	// see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5155
	EvalDelay   *promutils.Duration `yaml:"eval_delay,omitempty"`
	Limit       int                 `yaml:"limit,omitempty"`
	Rules       []Rule              `yaml:"rules"`
	Concurrency int                 `yaml:"concurrency"`
	// Labels is a set of label value pairs, that will be added to every rule.
	// It has priority over the external labels.
	Labels map[string]string `yaml:"labels"`
	// Checksum stores the hash of yaml definition for this group.
	// May be used to detect any changes like rules re-ordering etc.
	Checksum string
	// Optional HTTP URL parameters added to each rule request
	Params url.Values `yaml:"params"`
	// Headers contains optional HTTP headers added to each rule request
	Headers []Header `yaml:"headers,omitempty"`
	// NotifierHeaders contains optional HTTP headers sent to notifiers for generated notifications
	NotifierHeaders []Header `yaml:"notifier_headers,omitempty"`
	// EvalAlignment will make the timestamp of group query requests be aligned with interval
	EvalAlignment *bool `yaml:"eval_alignment,omitempty"`
	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

Group contains list of Rules grouped into entity with one name and evaluation interval

func Parse

func Parse(pathPatterns []string, validateTplFn ValidateTplFn, validateExpressions bool) ([]Group, error)

Parse parses rule configs from given file patterns

func ParseSilent added in v1.89.0

func ParseSilent(pathPatterns []string, validateTplFn ValidateTplFn, validateExpressions bool) ([]Group, error)

ParseSilent parses rule configs from given file patterns without emitting logs

func (*Group) UnmarshalYAML added in v1.41.0

func (g *Group) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

func (*Group) Validate added in v1.37.0

func (g *Group) Validate(validateTplFn ValidateTplFn, validateExpressions bool) error

Validate checks configuration errors for group and internal rules

type Header struct {
	Key   string
	Value string
}

Header is a Key - Value struct for holding an HTTP header.

func (*Header) UnmarshalYAML added in v1.80.0

func (h *Header) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Rule added in v1.34.4

type Rule struct {
	ID     uint64
	Record string              `yaml:"record,omitempty"`
	Alert  string              `yaml:"alert,omitempty"`
	Expr   string              `yaml:"expr"`
	For    *promutils.Duration `yaml:"for,omitempty"`
	// Alert will continue firing for this long even when the alerting expression no longer has results.
	KeepFiringFor *promutils.Duration `yaml:"keep_firing_for,omitempty"`
	Labels        map[string]string   `yaml:"labels,omitempty"`
	Annotations   map[string]string   `yaml:"annotations,omitempty"`
	Debug         bool                `yaml:"debug,omitempty"`
	// UpdateEntriesLimit defines max number of rule's state updates stored in memory.
	// Overrides `-rule.updateEntriesLimit`.
	UpdateEntriesLimit *int `yaml:"update_entries_limit,omitempty"`

	// Catches all undefined fields and must be empty after parsing.
	XXX map[string]interface{} `yaml:",inline"`
}

Rule describes entity that represent either recording rule or alerting rule.

func (*Rule) Name added in v1.34.4

func (r *Rule) Name() string

Name returns Rule name according to its type

func (*Rule) String added in v1.82.0

func (r *Rule) String() string

String implements Stringer interface

func (*Rule) UnmarshalYAML added in v1.37.1

func (r *Rule) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

func (*Rule) Validate added in v1.37.0

func (r *Rule) Validate() error

Validate check for Rule configuration errors

type Type added in v1.80.0

type Type struct {
	Name string
}

Type represents data source type

func NewGraphiteType added in v1.80.0

func NewGraphiteType() Type

NewGraphiteType returns graphite datasource type

func NewPrometheusType added in v1.80.0

func NewPrometheusType() Type

NewPrometheusType returns prometheus datasource type

func NewRawType added in v1.80.0

func NewRawType(d string) Type

NewRawType returns datasource type from raw string without validation.

func (*Type) Get added in v1.80.0

func (t *Type) Get() string

Get returns datasource type

func (Type) MarshalYAML added in v1.80.0

func (t Type) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Unmarshaler interface.

func (*Type) Set added in v1.80.0

func (t *Type) Set(d Type)

Set changes datasource type

func (Type) String added in v1.80.0

func (t Type) String() string

String implements String interface with default value.

func (*Type) UnmarshalYAML added in v1.80.0

func (t *Type) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

func (*Type) ValidateExpr added in v1.80.0

func (t *Type) ValidateExpr(expr string) error

ValidateExpr validates query expression with datasource ql.

type ValidateTplFn added in v1.80.0

type ValidateTplFn func(annotations map[string]string) error

ValidateTplFn must validate the given annotations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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