Categorygithub.com/influxdata/promql/v2
modulepackage
2.12.0
Repository: https://github.com/influxdata/promql.git
Documentation: pkg.go.dev

# README

PromQL Module

GoDoc

The PromQL module in this package is a pruned version of the native Prometheus promql package, but extracted into a single module with fewer dependencies.

This module removes the promql engine and keeps anything related to lexing and parsing the PromQL language.

Each version of this module matches with the equivalent Prometheus version.

Example

The PromQL module can be used to parse an expression.

package main

import (
    "fmt"

    "github.com/influxdata/promql/v2"
)

var myExpression = `http_requests_total{job="prometheus"}[5m]`

func main() {
    expr, err := promql.ParseExpr(myExpression)
    if err != nil {
        panic(err)
    }

    fmt.Println(promql.Tree(expr))
}

Contributing

Any changes to PromQL should not be made to this module as it is a pruned mirror of the original prometheus package. Changes should be submitted to the upstream Prometheus project and they will find their way into this repository when a new release happens.

The only changes that will be accepted into this repository are ones that fix a problem in the mirroring process, deviations from the upstream Prometheus, or operational changes to fulfill the primary purpose of this repository as a mirror of the promql package.

# Packages

No description provided by the author
No description provided by the author

# Functions

Inspect traverses an AST in depth-first order: It starts by calling f(node, path); node must not be nil.
ParseExpr returns the expression parsed from the input.
ParseMetric parses the input into a metric.
ParseMetricSelector parses the provided textual metric selector into a list of label matchers.
Tree returns a string of the tree structure of the given node.
Walk traverses an AST in depth-first order: It starts by calling v.Visit(node, path); node must not be nil.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Aggregators.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Error occurred, value is error message.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Keywords.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Operators.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Non-operators.
The valid value types.
The valid value types.
The valid value types.
The valid value types.
The valid value types.

# Structs

AggregateExpr represents an aggregation operation on a Vector.
BinaryExpr represents a binary expression between two child expressions.
Call represents a function call.
EvalStmt holds an expression and information on the range it should be evaluated on.
Function represents a function of the expression language and is used by function nodes.
MatrixSelector represents a Matrix selection.
NumberLiteral represents a number.
ParenExpr wraps an expression so it cannot be disassembled as a consequence of operator precedence.
ParseErr wraps a parsing error with line and position context.
Point represents a single data point for a given timestamp.
Sample is a single sample belonging to a metric.
Scalar is a data point that's explicitly not associated with a metric.
Series is a stream of data points belonging to a metric.
String represents a string value.
StringLiteral represents a string.
SubqueryExpr represents a subquery.
UnaryExpr represents a unary operation on another expression.
VectorMatching describes how elements from two Vectors in a binary operation are supposed to be matched.
VectorSelector represents a Vector selection.

# Interfaces

Expr is a generic interface for all expression types.
Node is a generic interface for all nodes in an AST.
Statement is a generic interface for all statements.
Value is a generic interface for values resulting from a query evaluation.
Visitor allows visiting a Node and its child nodes.

# Type aliases

Expressions is a list of expression nodes that implements Node.
No description provided by the author
Matrix is a slice of Series that implements sort.Interface and has a String method.
Pos is the position in a string.
ValueType describes a type of a value.
Vector is basically only an alias for model.Samples, but the contract is that in a Vector, all Samples have the same timestamp.
VectorMatchCardinality describes the cardinality relationship of two Vectors in a binary operation.