rulefmt

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Group string
	Rule  int
	Err   error
}

Error represents semantical errors on parsing rule groups.

func (*Error) Error

func (err *Error) Error() string

type Rule

type Rule struct {
	Record      string            `yaml:"record,omitempty"`
	Alert       string            `yaml:"alert,omitempty"`
	Expr        string            `yaml:"expr"`
	For         model.Duration    `yaml:"for,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`

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

Rule describes an alerting or recording rule.

func (*Rule) Validate

func (r *Rule) Validate() (errs []error)

Validate the rule and return a list of encountered errors.

type RuleGroup

type RuleGroup struct {
	Name     string         `yaml:"name"`
	Interval model.Duration `yaml:"interval,omitempty"`
	Rules    []Rule         `yaml:"rules"`

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

RuleGroup is a list of sequentially evaluated recording and alerting rules.

type RuleGroups

type RuleGroups struct {
	Groups []RuleGroup `yaml:"groups"`

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

RuleGroups is a set of rule groups that are typically exposed in a file.

func ParseFile

func ParseFile(file string) (*RuleGroups, []error)

ParseFile parses the rule file and validates it.

func (*RuleGroups) Validate

func (g *RuleGroups) Validate() (errs []error)

Validate validates all rules in the rule groups.

Jump to

Keyboard shortcuts

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