mql

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHAggNone = "_"

	CHAggMin    = "min"
	CHAggMax    = "max"
	CHAggSum    = "sum"
	CHAggAvg    = "avg"
	CHAggMedian = "median"

	CHAggUniq = "uniq"

	// Histograms only.
	CHAggCount = "count"
	CHAggP50   = "p50"
	CHAggP75   = "p75"
	CHAggP90   = "p90"
	CHAggP95   = "p95"
	CHAggP99   = "p99"
)
View Source
const (
	GoAggMin    = "min"
	GoAggMax    = "max"
	GoAggSum    = "sum"
	GoAggAvg    = "avg"
	GoAggMedian = "median"
)
View Source
const (
	TableFuncMin    = "min"
	TableFuncMax    = "max"
	TableFuncSum    = "sum"
	TableFuncAvg    = "avg"
	TableFuncMedian = "median"
	TableFuncLast   = "last"
)
View Source
const (
	TransformPerMin = "per_min"
	TransformPerSec = "per_sec"
	TransformAbs    = "abs"
	TransformCeil   = "ceil"
	TransformFloor  = "floor"
	TransformTrunc  = "trunc"
	TransformCos    = "cos"
	TransformCosh   = "cosh"
	TransformAcos   = "acos"
	TransformAcosh  = "acosh"
	TransformSin    = "sin"
	TransformSinh   = "sinh"
	TransformAsin   = "asin"
	TransformAsinh  = "asinh"
	TransformTan    = "tan"
	TransformTanh   = "tanh"
	TransformAtan   = "atan"
	TransformAtanh  = "atanh"
	TransformExp    = "exp"
	TransformExp2   = "exp2"
	TransformLog    = "log"
	TransformLog2   = "log2"
	TransformLog10  = "log10"
	TransformLn     = "ln"
)
View Source
const (
	RollupIncrease       = "increase"
	RollupDelta          = "delta"
	RollupRate           = "rate"
	RollupIRate          = "irate"
	RollupMinOverTime    = "min_over_time"
	RollupMaxOverTime    = "max_over_time"
	RollupSumOverTime    = "sum_over_time"
	RollupAvgOverTime    = "avg_over_time"
	RollupMedianOverTime = "median_over_time"
)

Variables

This section is empty.

Functions

func JoinQuery

func JoinQuery(parts []string) string

func Median added in v1.6.2

func Median(value []float64) float64

func ParseColumns

func ParseColumns(queryStr string) (map[string]ast.Expr, error)

func SortAttrs

func SortAttrs(attrs Attrs)

func SplitQuery

func SplitQuery(query string) []string

func TableFuncName

func TableFuncName(expr ast.Expr) string

Types

type Attrs

type Attrs []KeyValue

func AttrsFromKeysValues

func AttrsFromKeysValues(keys, values []string) Attrs

func AttrsFromMap

func AttrsFromMap(m map[string]string) Attrs

func NewAttrs

func NewAttrs(ss ...string) Attrs

func (Attrs) AppendString

func (attrs Attrs) AppendString(b []byte, sep string) []byte

func (Attrs) Bytes

func (attrs Attrs) Bytes(buf []byte, pick map[string]struct{}) []byte

func (Attrs) Map

func (attrs Attrs) Map() map[string]string

func (Attrs) MarshalJSON

func (attrs Attrs) MarshalJSON() ([]byte, error)

func (Attrs) Pick

func (attrs Attrs) Pick(grouping map[string]struct{}) Attrs

func (Attrs) SortedKeys

func (attrs Attrs) SortedKeys() []string

func (Attrs) String

func (attrs Attrs) String() string

func (*Attrs) UnmarshalJSON

func (attrs *Attrs) UnmarshalJSON(b []byte) error

type BinaryExpr

type BinaryExpr struct {
	Op  ast.BinaryOp
	LHS Expr
	RHS Expr
}

type ColumnInfo

type ColumnInfo struct{}

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(
	storage Storage,
	timeGTE, timeLT unixtime.Seconds,
	interval time.Duration,
) *Engine

func (*Engine) Run

func (e *Engine) Run(parts []*QueryPart) *Result

type Expr

type Expr interface{}

type FuncCall

type FuncCall struct {
	Func     string
	Arg      Expr
	Grouping []string
}

type JSONError

type JSONError struct {
	Wrapped error
}

func (JSONError) MarshalJSON

func (e JSONError) MarshalJSON() ([]byte, error)

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

func (KeyValue) AppendString

func (kv KeyValue) AppendString(b []byte) []byte

type MetricAlias

type MetricAlias struct {
	Name  string `yaml:"name" json:"name"`
	Alias string `yaml:"alias" json:"alias"`
}

func (*MetricAlias) String

func (m *MetricAlias) String() string

func (*MetricAlias) Validate

func (m *MetricAlias) Validate() error

type MetricInfo

type MetricInfo struct {
	Name      string
	TableFunc string
}

type NamedExpr

type NamedExpr struct {
	Part     *QueryPart
	AST      ast.Expr
	Expr     Expr
	HasAlias bool
	Alias    string
}

func (*NamedExpr) NameTemplate

func (e *NamedExpr) NameTemplate() string

type ParenExpr

type ParenExpr struct {
	Expr Expr
}

type ParsedQuery

type ParsedQuery struct {
	Parts   []*QueryPart  `json:"parts"`
	Columns []*ColumnInfo `json:"columns"`
}

func ParseQuery

func ParseQuery(query string) *ParsedQuery

func ParseQueryError

func ParseQueryError(query string) (*ParsedQuery, error)

func (*ParsedQuery) String

func (q *ParsedQuery) String() string

type QueryPart

type QueryPart struct {
	Query    string    `json:"query"`
	Error    JSONError `json:"error,omitempty"`
	Disabled bool      `json:"disabled,omitempty"`

	AST any `json:"-"`
}

type RefExpr

type RefExpr struct {
	Name string
}

type Result

type Result struct {
	Metrics    []MetricInfo
	Timeseries []*Timeseries
}

type Storage

type Storage interface {
	SelectTimeseries(f *TimeseriesFilter) ([]*Timeseries, error)
}

type Timeseries

type Timeseries struct {
	MetricName   string
	NameTemplate string

	Unit     string
	Filters  []ast.Filter
	Grouping []string

	Attrs       Attrs
	Annotations map[string]any

	Value []float64
	Time  []unixtime.Seconds
}

func (*Timeseries) Clone

func (ts *Timeseries) Clone() *Timeseries

func (*Timeseries) DeepClone

func (ts *Timeseries) DeepClone() *Timeseries

func (*Timeseries) Name

func (ts *Timeseries) Name() string

func (*Timeseries) TrimNaNLeft added in v1.7.0

func (ts *Timeseries) TrimNaNLeft()

func (*Timeseries) WhereQuery

func (ts *Timeseries) WhereQuery() string

type TimeseriesExpr

type TimeseriesExpr struct {
	Metric       string
	RollupWindow time.Duration
	Offset       time.Duration

	CHFunc string
	Attr   string

	Uniq []string

	Filters  []ast.Filter
	Where    [][]ast.Filter
	Grouping []ast.GroupingElem

	Part       *QueryPart
	Timeseries []*Timeseries
}

type TimeseriesFilter

type TimeseriesFilter struct {
	Metric string

	TimeGTE  time.Time
	TimeLT   time.Time
	Interval time.Duration

	CHFunc string
	Attr   string

	Uniq []string

	Filters  []ast.Filter
	Where    [][]ast.Filter
	Grouping ast.GroupingElems
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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