Documentation ¶
Index ¶
- Constants
- func CompareGroups(groupOne, groupTwo rwrulefmt.RuleGroup) error
- func ParseFiles(files []string) (map[string]RuleNamespace, error)
- func PrintComparisonResult(results []NamespaceChange, verbose bool) error
- func SummarizeChanges(changes []NamespaceChange) (created, updated, deleted int)
- func ValidateRuleGroup(g rwrulefmt.RuleGroup) []error
- type NamespaceChange
- type NamespaceState
- type RuleNamespace
- type UpdatedRuleGroup
Constants ¶
const (
LokiBackend = "loki"
)
Variables ¶
This section is empty.
Functions ¶
func CompareGroups ¶
CompareGroups differentiates between two rule groups
func ParseFiles ¶
func ParseFiles(files []string) (map[string]RuleNamespace, error)
ParseFiles returns a formatted set of prometheus rule groups
func PrintComparisonResult ¶
func PrintComparisonResult(results []NamespaceChange, verbose bool) error
PrintComparisonResult prints the differences between the staged namespace and active namespace
func SummarizeChanges ¶
func SummarizeChanges(changes []NamespaceChange) (created, updated, deleted int)
SummarizeChanges returns the number of each type of change in a set of changes
func ValidateRuleGroup ¶
ValidateRuleGroup validates a rulegroup
Types ¶
type NamespaceChange ¶
type NamespaceChange struct { Namespace string State NamespaceState GroupsUpdated []UpdatedRuleGroup GroupsCreated []rwrulefmt.RuleGroup GroupsDeleted []rwrulefmt.RuleGroup }
NamespaceChange stores the various changes between a staged set of changes and the active rules configs.
func CompareNamespaces ¶
func CompareNamespaces(original, new RuleNamespace) NamespaceChange
CompareNamespaces returns the differences between the two provided namespaces
type NamespaceState ¶
type NamespaceState int
NamespaceState is used to denote the difference between the staged namespace and active namespace for the Loki tenant
const ( // Unchanged denotes the active namespace is identical to the staged namespace Unchanged NamespaceState = iota // Created denotes their is not active namespace for the staged namespace Created // Updated denotes the active namespace is different than the staged namespace Updated // Deleted denotes their is no staged namespace for the active namespace Deleted )
type RuleNamespace ¶
type RuleNamespace struct { // Namespace field only exists for setting namespace in namespace body instead of file name Namespace string `yaml:"namespace,omitempty"` Filepath string `yaml:"-"` Groups []rwrulefmt.RuleGroup `yaml:"groups"` }
RuleNamespace is used to parse a slightly modified prometheus rule file format, if no namespace is set, the default namespace is used. Namespace is functionally the same as a file name.
func Parse ¶
func Parse(f string) ([]RuleNamespace, []error)
Parse parses and validates a set of rules.
func ParseBytes ¶
func ParseBytes(content []byte) ([]RuleNamespace, []error)
func ParseLoki ¶
func ParseLoki(f string) ([]RuleNamespace, []error)
func (RuleNamespace) AggregateBy ¶
func (r RuleNamespace) AggregateBy(label string, applyTo func(group rwrulefmt.RuleGroup, rule rulefmt.RuleNode) bool) (int, int, error)
AggregateBy modifies the aggregation rules in groups to include a given Label. If the applyTo function is provided, the aggregation is applied only to rules for which the applyTo function returns true.
func (RuleNamespace) CheckRecordingRules ¶
func (r RuleNamespace) CheckRecordingRules(strict bool) int
CheckRecordingRules checks that recording rules have at least one colon in their name, this is based on the recording rules best practices here: https://prometheus.io/docs/practices/rules/ Returns the number of rules that don't match the requirements.
func (RuleNamespace) LintExpressions ¶
func (r RuleNamespace) LintExpressions() (int, int, error)
LintExpressions runs the `expr` from a rule through the PromQL or LogQL parser and compares its output. If it differs from the parser, it uses the parser's instead.
func (RuleNamespace) Validate ¶
func (r RuleNamespace) Validate() []error
Validate each rule in the rule namespace is valid