Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRuleCommentOnFile = errors.New("this comment is only valid when attached to a rule")
Functions ¶
This section is empty.
Types ¶
type AlertingRule ¶
type AlertingRule struct { Expr PromQLExpr For *YamlNode KeepFiringFor *YamlNode Labels *YamlMap Annotations *YamlMap Alert YamlNode }
func (*AlertingRule) IsIdentical ¶ added in v0.50.0
func (ar *AlertingRule) IsIdentical(b *AlertingRule) bool
type ParseError ¶
Use insread of StrictError.
func (ParseError) Error ¶ added in v0.61.0
func (pe ParseError) Error() string
type PromQLExpr ¶
type PromQLExpr struct { Value *YamlNode SyntaxError error Query *PromQLNode }
func (PromQLExpr) IsIdentical ¶ added in v0.50.0
func (pqle PromQLExpr) IsIdentical(b PromQLExpr) bool
type PromQLNode ¶
type PromQLNode struct { Parent *PromQLNode Expr promParser.Node Children []*PromQLNode }
PromQLNode is used to turn the parsed PromQL query expression into a tree. This allows us to walk the tree up & down and look for either parents or children of specific type. Which is useful if you, for example, want to check if all vector selectors are wrapped inside function calls etc.
func DecodeExpr ¶ added in v0.2.0
func DecodeExpr(expr string) (*PromQLNode, error)
func WalkDownExpr ¶ added in v0.56.0
func WalkDownExpr[T promParser.Node](node *PromQLNode) (nodes []*PromQLNode)
WalkDownExpr works just like WalkUpExpr but it walks the tree down, visiting all children. It also starts by checking the node passed to it before walking down the tree.
func WalkUpExpr ¶ added in v0.56.0
func WalkUpExpr[T promParser.Node](node *PromQLNode) (nodes []*PromQLNode)
WalkUpExpr allows to iterate a promQLNode node looking for parents of specific type. Prometheus parser returns interfaces which makes it more difficult to figure out what kind of node we're dealing with, hence this helper takes a type parameter it tries to cast. It starts by checking the node passed to it and then walks up by visiting all parent nodes.
func WalkUpParent ¶ added in v0.56.0
func WalkUpParent[T promParser.Node](node *PromQLNode) (nodes []*PromQLNode)
WalkUpParent works like WalkUpExpr but checks the parent (if present) instead of the node itself. It returns the nodes where the parent is of given type.
func (PromQLNode) MarshalJSON ¶ added in v0.56.0
func (pn PromQLNode) MarshalJSON() ([]byte, error)
type RecordingRule ¶
type RecordingRule struct { Expr PromQLExpr Labels *YamlMap Record YamlNode }
func (*RecordingRule) IsIdentical ¶ added in v0.50.0
func (rr *RecordingRule) IsIdentical(b *RecordingRule) bool
type Rule ¶
type Rule struct { AlertingRule *AlertingRule RecordingRule *RecordingRule Error ParseError Comments []comments.Comment Lines LineRange }
func (Rule) Expr ¶
func (r Rule) Expr() PromQLExpr
func (Rule) IsIdentical ¶ added in v0.50.0
type YamlKeyValue ¶
type YamlMap ¶
type YamlMap struct { Key *YamlNode Items []*YamlKeyValue Lines LineRange }