diff --git a/docs/querying/functions.md b/docs/querying/functions.md index 079a1e320..33740ac4a 100644 --- a/docs/querying/functions.md +++ b/docs/querying/functions.md @@ -434,3 +434,26 @@ over time and return an instant vector with per-series aggregation results: Note that all values in the specified interval have the same weight in the aggregation even if the values are not equally spaced throughout the interval. + +## Trigonometric Functions + +The trigonometric functions work in radians: + +- `acos(v instant-vector)`: calculates the arccosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Acos)). +- `acosh(v instant-vector)`: calculates the inverse hyperbolic cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Acosh)). +- `asin(v instant-vector)`: calculates the arcsine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asin)). +- `asinh(v instant-vector)`: calculates the inverse hyperbolic sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Asinh)). +- `atan(v instant-vector)`: calculates the arctangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atan)). +- `atanh(v instant-vector)`: calculates the inverse hyperbolic tangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Atanh)). +- `cos(v instant-vector)`: calculates the cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cos)). +- `cosh(v instant-vector)`: calculates the hyperbolic cosine of all elements in `v` ([special cases](https://pkg.go.dev/math#Cosh)). +- `sin(v instant-vector)`: calculates the sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Sin)). +- `sinh(v instant-vector)`: calculates the hyperbolic sine of all elements in `v` ([special cases](https://pkg.go.dev/math#Sinh)). +- `tan(v instant-vector)`: calculates the tangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Tan)). +- `tanh(v instant-vector)`: calculates the hyperbolic tangent of all elements in `v` ([special cases](https://pkg.go.dev/math#Tanh)). + +The following are useful for converting between degrees and radians: + +- `deg(v instant-vector)`: converts radians to degrees for all elements in `v`. +- `pi()`: returns pi. +- `rad(v instant-vector)`: converts degrees to radians for all elements in `v`. \ No newline at end of file diff --git a/promql/functions.go b/promql/functions.go index d72b4caf6..50594503d 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -570,6 +570,87 @@ func funcLog10(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper return simpleFunc(vals, enh, math.Log10) } +// === sin(Vector parser.ValueTypeVector) Vector === +func funcSin(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Sin) +} + +// === cos(Vector parser.ValueTypeVector) Vector === +func funcCos(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Cos) +} + +// === tan(Vector parser.ValueTypeVector) Vector === +func funcTan(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Tan) +} + +// == asin(Vector parser.ValueTypeVector) Vector === +func funcAsin(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Asin) +} + +// == acos(Vector parser.ValueTypeVector) Vector === +func funcAcos(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Acos) +} + +// == atan(Vector parser.ValueTypeVector) Vector === +func funcAtan(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Atan) +} + +// == sinh(Vector parser.ValueTypeVector) Vector === +func funcSinh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Sinh) +} + +// == cosh(Vector parser.ValueTypeVector) Vector === +func funcCosh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Cosh) +} + +// == tanh(Vector parser.ValueTypeVector) Vector === +func funcTanh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Tanh) +} + +// == asinh(Vector parser.ValueTypeVector) Vector === +func funcAsinh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Asinh) +} + +// == acosh(Vector parser.ValueTypeVector) Vector === +func funcAcosh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Acosh) +} + +// == atanh(Vector parser.ValueTypeVector) Vector === +func funcAtanh(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, math.Atanh) +} + +// === rad(Vector parser.ValueTypeVector) Vector === +func funcRad(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, func(v float64) float64 { + return v * math.Pi / 180 + }) +} + +// === deg(Vector parser.ValueTypeVector) Vector === +func funcDeg(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return simpleFunc(vals, enh, func(v float64) float64 { + return v * 180 / math.Pi + }) +} + +// === pi() Scalar === +func funcPi(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { + return Vector{Sample{Point: Point{ + V: math.Pi, + }}} +} + // === sgn(Vector parser.ValueTypeVector) Vector === func funcSgn(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) Vector { return simpleFunc(vals, enh, func(v float64) float64 { @@ -935,16 +1016,25 @@ var FunctionCalls = map[string]FunctionCall{ "abs": funcAbs, "absent": funcAbsent, "absent_over_time": funcAbsentOverTime, + "acos": funcAcos, + "acosh": funcAcosh, + "asin": funcAsin, + "asinh": funcAsinh, + "atan": funcAtan, + "atanh": funcAtanh, "avg_over_time": funcAvgOverTime, "ceil": funcCeil, "changes": funcChanges, "clamp": funcClamp, "clamp_max": funcClampMax, "clamp_min": funcClampMin, + "cos": funcCos, + "cosh": funcCosh, "count_over_time": funcCountOverTime, "days_in_month": funcDaysInMonth, "day_of_month": funcDayOfMonth, "day_of_week": funcDayOfWeek, + "deg": funcDeg, "delta": funcDelta, "deriv": funcDeriv, "exp": funcExp, @@ -965,20 +1055,26 @@ var FunctionCalls = map[string]FunctionCall{ "min_over_time": funcMinOverTime, "minute": funcMinute, "month": funcMonth, + "pi": funcPi, "predict_linear": funcPredictLinear, "present_over_time": funcPresentOverTime, "quantile_over_time": funcQuantileOverTime, + "rad": funcRad, "rate": funcRate, "resets": funcResets, "round": funcRound, "scalar": funcScalar, "sgn": funcSgn, + "sin": funcSin, + "sinh": funcSinh, "sort": funcSort, "sort_desc": funcSortDesc, "sqrt": funcSqrt, "stddev_over_time": funcStddevOverTime, "stdvar_over_time": funcStdvarOverTime, "sum_over_time": funcSumOverTime, + "tan": funcTan, + "tanh": funcTanh, "time": funcTime, "timestamp": funcTimestamp, "vector": funcVector, diff --git a/promql/parser/functions.go b/promql/parser/functions.go index da5d279f3..c4bc5ddb8 100644 --- a/promql/parser/functions.go +++ b/promql/parser/functions.go @@ -39,9 +39,34 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeMatrix}, ReturnType: ValueTypeVector, }, - "present_over_time": { - Name: "present_over_time", - ArgTypes: []ValueType{ValueTypeMatrix}, + "acos": { + Name: "acos", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "acosh": { + Name: "acosh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "asin": { + Name: "asin", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "asinh": { + Name: "asinh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "atan": { + Name: "atan", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "atanh": { + Name: "atanh", + ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, "avg_over_time": { @@ -74,6 +99,16 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector, ValueTypeScalar}, ReturnType: ValueTypeVector, }, + "cos": { + Name: "cos", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "cosh": { + Name: "cosh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "count_over_time": { Name: "count_over_time", ArgTypes: []ValueType{ValueTypeMatrix}, @@ -97,6 +132,11 @@ var Functions = map[string]*Function{ Variadic: 1, ReturnType: ValueTypeVector, }, + "deg": { + Name: "deg", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "delta": { Name: "delta", ArgTypes: []ValueType{ValueTypeMatrix}, @@ -201,16 +241,31 @@ var Functions = map[string]*Function{ Variadic: 1, ReturnType: ValueTypeVector, }, + "pi": { + Name: "pi", + ArgTypes: []ValueType{}, + ReturnType: ValueTypeScalar, + }, "predict_linear": { Name: "predict_linear", ArgTypes: []ValueType{ValueTypeMatrix, ValueTypeScalar}, ReturnType: ValueTypeVector, }, + "present_over_time": { + Name: "present_over_time", + ArgTypes: []ValueType{ValueTypeMatrix}, + ReturnType: ValueTypeVector, + }, "quantile_over_time": { Name: "quantile_over_time", ArgTypes: []ValueType{ValueTypeScalar, ValueTypeMatrix}, ReturnType: ValueTypeVector, }, + "rad": { + Name: "rad", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "rate": { Name: "rate", ArgTypes: []ValueType{ValueTypeMatrix}, @@ -237,6 +292,16 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeVector}, ReturnType: ValueTypeVector, }, + "sin": { + Name: "sin", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "sinh": { + Name: "sinh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "sort": { Name: "sort", ArgTypes: []ValueType{ValueTypeVector}, @@ -267,6 +332,16 @@ var Functions = map[string]*Function{ ArgTypes: []ValueType{ValueTypeMatrix}, ReturnType: ValueTypeVector, }, + "tan": { + Name: "tan", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, + "tanh": { + Name: "tanh", + ArgTypes: []ValueType{ValueTypeVector}, + ReturnType: ValueTypeVector, + }, "time": { Name: "time", ArgTypes: []ValueType{}, diff --git a/promql/testdata/trig_functions.test b/promql/testdata/trig_functions.test new file mode 100644 index 000000000..fa5f94651 --- /dev/null +++ b/promql/testdata/trig_functions.test @@ -0,0 +1,101 @@ +# Testing sin() cos() tan() asin() acos() atan() sinh() cosh() tanh() rad() deg() pi(). + +load 5m + trig{l="x"} 10 + trig{l="y"} 20 + trig{l="NaN"} NaN + +eval instant at 5m sin(trig) + {l="x"} -0.5440211108893699 + {l="y"} 0.9129452507276277 + {l="NaN"} NaN + +eval instant at 5m cos(trig) + {l="x"} -0.8390715290764524 + {l="y"} 0.40808206181339196 + {l="NaN"} NaN + +eval instant at 5m tan(trig) + {l="x"} 0.6483608274590867 + {l="y"} 2.2371609442247427 + {l="NaN"} NaN + +eval instant at 5m asin(trig - 10.1) + {l="x"} -0.10016742116155944 + {l="y"} NaN + {l="NaN"} NaN + +eval instant at 5m acos(trig - 10.1) + {l="x"} 1.670963747956456 + {l="y"} NaN + {l="NaN"} NaN + +eval instant at 5m atan(trig) + {l="x"} 1.4711276743037345 + {l="y"} 1.5208379310729538 + {l="NaN"} NaN + +eval instant at 5m sinh(trig) + {l="x"} 11013.232920103324 + {l="y"} 2.4258259770489514e+08 + {l="NaN"} NaN + +eval instant at 5m cosh(trig) + {l="x"} 11013.232920103324 + {l="y"} 2.4258259770489514e+08 + {l="NaN"} NaN + +eval instant at 5m tanh(trig) + {l="x"} 0.9999999958776927 + {l="y"} 1 + {l="NaN"} NaN + +eval instant at 5m asinh(trig) + {l="x"} 2.99822295029797 + {l="y"} 3.6895038689889055 + {l="NaN"} NaN + +eval instant at 5m acosh(trig) + {l="x"} 2.993222846126381 + {l="y"} 3.6882538673612966 + {l="NaN"} NaN + +eval instant at 5m atanh(trig - 10.1) + {l="x"} -0.10033534773107522 + {l="y"} NaN + {l="NaN"} NaN + +eval instant at 5m rad(trig) + {l="x"} 0.17453292519943295 + {l="y"} 0.3490658503988659 + {l="NaN"} NaN + +eval instant at 5m rad(trig - 10) + {l="x"} 0 + {l="y"} 0.17453292519943295 + {l="NaN"} NaN + +eval instant at 5m rad(trig - 20) + {l="x"} -0.17453292519943295 + {l="y"} 0 + {l="NaN"} NaN + +eval instant at 5m deg(trig) + {l="x"} 572.9577951308232 + {l="y"} 1145.9155902616465 + {l="NaN"} NaN + +eval instant at 5m deg(trig - 10) + {l="x"} 0 + {l="y"} 572.9577951308232 + {l="NaN"} NaN + +eval instant at 5m deg(trig - 20) + {l="x"} -572.9577951308232 + {l="y"} 0 + {l="NaN"} NaN + +clear + +eval instant at 0s pi() + 3.141592653589793 diff --git a/web/ui/module/codemirror-promql/src/complete/promql.terms.ts b/web/ui/module/codemirror-promql/src/complete/promql.terms.ts index a669e78c5..3caf235bf 100644 --- a/web/ui/module/codemirror-promql/src/complete/promql.terms.ts +++ b/web/ui/module/codemirror-promql/src/complete/promql.terms.ts @@ -64,6 +64,42 @@ export const functionIdentifierTerms = [ info: 'Determine whether input range vector is empty', type: 'function', }, + { + label: 'acos', + detail: 'function', + info: 'Calculate the arccosine, in radians, for input series', + type: 'function', + }, + { + label: 'acosh', + detail: 'function', + info: 'Calculate the inverse hyperbolic cosine, in radians, for input series', + type: 'function', + }, + { + label: 'asin', + detail: 'function', + info: 'Calculate the arcsine, in radians, for input series', + type: 'function', + }, + { + label: 'asinh', + detail: 'function', + info: 'Calculate the inverse hyperbolic sine, in radians, for input series', + type: 'function', + }, + { + label: 'atan', + detail: 'function', + info: 'Calculate the arctangent, in radians, for input series', + type: 'function', + }, + { + label: 'atanh', + detail: 'function', + info: 'Calculate the inverse hyperbolic tangent, in radians, for input series', + type: 'function', + }, { label: 'avg_over_time', detail: 'function', @@ -100,6 +136,18 @@ export const functionIdentifierTerms = [ info: 'Limit the value of input series to a minimum', type: 'function', }, + { + label: 'cos', + detail: 'function', + info: 'Calculate the cosine, in radians, for input series', + type: 'function', + }, + { + label: 'cosh', + detail: 'function', + info: 'Calculate the hyperbolic cosine, in radians, for input series', + type: 'function', + }, { label: 'count_over_time', detail: 'function', @@ -124,6 +172,12 @@ export const functionIdentifierTerms = [ info: 'Return the day of the week for provided timestamps', type: 'function', }, + { + label: 'deg', + detail: 'function', + info: 'Convert radians to degrees for input series', + type: 'function', + }, { label: 'delta', detail: 'function', @@ -244,6 +298,12 @@ export const functionIdentifierTerms = [ info: 'Return the month for provided timestamps', type: 'function', }, + { + label: 'pi', + detail: 'function', + info: 'Return pi', + type: 'function', + }, { label: 'predict_linear', detail: 'function', @@ -262,6 +322,12 @@ export const functionIdentifierTerms = [ info: 'Calculate value quantiles over time for input series', type: 'function', }, + { + label: 'rad', + detail: 'function', + info: 'Convert degrees to radians for input series', + type: 'function', + }, { label: 'rate', detail: 'function', @@ -292,6 +358,18 @@ export const functionIdentifierTerms = [ info: 'Returns the sign of the instant vector', type: 'function', }, + { + label: 'sin', + detail: 'function', + info: 'Calculate the sine, in radians, for input series', + type: 'function', + }, + { + label: 'sinh', + detail: 'function', + info: 'Calculate the hyperbolic sine, in radians, for input series', + type: 'function', + }, { label: 'sort', detail: 'function', @@ -328,6 +406,18 @@ export const functionIdentifierTerms = [ info: 'Calculate the sum over the values of input series over time', type: 'function', }, + { + label: 'tan', + detail: 'function', + info: 'Calculate the tangent, in radians, for input series', + type: 'function', + }, + { + label: 'tanh', + detail: 'function', + info: 'Calculate the hyperbolic tangent, in radians, for input series', + type: 'function', + }, { label: 'time', detail: 'function', diff --git a/web/ui/module/codemirror-promql/src/grammar/promql.grammar b/web/ui/module/codemirror-promql/src/grammar/promql.grammar index b5dac8bf7..2814a35c5 100644 --- a/web/ui/module/codemirror-promql/src/grammar/promql.grammar +++ b/web/ui/module/codemirror-promql/src/grammar/promql.grammar @@ -121,16 +121,25 @@ FunctionIdentifier { AbsentOverTime | Absent | Abs | + Acos | + Acosh | + Asin | + Asinh | + Atan | + Atanh | AvgOverTime | Ceil | Changes | Clamp | ClampMax | ClampMin | + Cos | + Cosh | CountOverTime | DaysInMonth | DayOfMonth | DayOfWeek | + Deg | Delta | Deriv | Exp | @@ -151,20 +160,26 @@ FunctionIdentifier { MinOverTime | Minute | Month | + Pi | PredictLinear | PresentOverTime | QuantileOverTime | + Rad | Rate | Resets | Round | Scalar | Sgn | + Sin | + Sinh | Sort | SortDesc | Sqrt | StddevOverTime | StdvarOverTime | SumOverTime | + Tan | + Tanh | Timestamp | Time | Vector | @@ -343,16 +358,25 @@ NumberLiteral { Abs { condFn<"abs"> } Absent { condFn<"absent"> } AbsentOverTime { condFn<"absent_over_time"> } + Acos { condFn<"acos"> } + Acosh { condFn<"acosh"> } + Asin { condFn<"asin"> } + Asinh { condFn<"asinh">} + Atan { condFn<"atan"> } + Atanh { condFn<"atanh">} AvgOverTime { condFn<"avg_over_time"> } Ceil { condFn<"ceil"> } Changes { condFn<"changes"> } Clamp { condFn<"clamp"> } ClampMax { condFn<"clamp_max"> } ClampMin { condFn<"clamp_min"> } + Cos { condFn<"cos">} + Cosh { condFn<"cosh">} CountOverTime { condFn<"count_over_time"> } DaysInMonth { condFn<"days_in_month"> } DayOfMonth { condFn<"day_of_month"> } DayOfWeek { condFn<"day_of_week"> } + Deg { condFn<"deg"> } Delta { condFn<"delta"> } Deriv { condFn<"deriv"> } Exp { condFn<"exp"> } @@ -373,20 +397,26 @@ NumberLiteral { MinOverTime { condFn<"min_over_time"> } Minute { condFn<"minute"> } Month { condFn<"month"> } + Pi { condFn<"pi">} PredictLinear { condFn<"predict_linear"> } PresentOverTime { condFn<"present_over_time"> } QuantileOverTime { condFn<"quantile_over_time"> } + Rad { condFn<"rad"> } Rate { condFn<"rate"> } Resets { condFn<"resets"> } Round { condFn<"round"> } Scalar { condFn<"scalar"> } Sgn { condFn<"sgn"> } + Sin { condFn<"sin">} + Sinh { condFn<"sinh"> } Sort { condFn<"sort"> } SortDesc { condFn<"sort_desc"> } Sqrt { condFn<"sqrt"> } StddevOverTime { condFn<"stddev_over_time"> } StdvarOverTime { condFn<"stdvar_over_time"> } SumOverTime { condFn<"sum_over_time"> } + Tan { condFn<"tan"> } + Tanh { condFn<"tanh">} Time { condFn<"time"> } Timestamp { condFn<"timestamp"> } Vector { condFn<"vector"> } diff --git a/web/ui/module/codemirror-promql/src/promql.ts b/web/ui/module/codemirror-promql/src/promql.ts index 0144c09c9..8d282572f 100644 --- a/web/ui/module/codemirror-promql/src/promql.ts +++ b/web/ui/module/codemirror-promql/src/promql.ts @@ -35,7 +35,7 @@ export function promQLLanguage(top: LanguageType): LezerLanguage { StringLiteral: tags.string, NumberLiteral: tags.number, Duration: tags.number, - 'Abs Absent AbsentOverTime AvgOverTime Ceil Changes Clamp ClampMax ClampMin CountOverTime DaysInMonth DayOfMonth DayOfWeek Delta Deriv Exp Floor HistogramQuantile HoltWinters Hour Idelta Increase Irate LabelReplace LabelJoin LastOverTime Ln Log10 Log2 MaxOverTime MinOverTime Minute Month PredictLinear PresentOverTime QuantileOverTime Rate Resets Round Scalar Sgn Sort SortDesc Sqrt StddevOverTime StdvarOverTime SumOverTime Time Timestamp Vector Year': + 'Abs Absent AbsentOverTime Acos Acosh Asin Asinh Atan Atanh AvgOverTime Ceil Changes Clamp ClampMax ClampMin Cos Cosh CountOverTime DaysInMonth DayOfMonth DayOfWeek Deg Delta Deriv Exp Floor HistogramQuantile HoltWinters Hour Idelta Increase Irate LabelReplace LabelJoin LastOverTime Ln Log10 Log2 MaxOverTime MinOverTime Minute Month Pi PredictLinear PresentOverTime QuantileOverTime Rad Rate Resets Round Scalar Sgn Sin Sinh Sort SortDesc Sqrt StddevOverTime StdvarOverTime SumOverTime Tan Tanh Time Timestamp Vector Year': tags.function(tags.variableName), 'Avg Bottomk Count Count_values Group Max Min Quantile Stddev Stdvar Sum Topk': tags.operatorKeyword, 'By Without Bool On Ignoring GroupLeft GroupRight Offset Start End': tags.modifier, diff --git a/web/ui/module/codemirror-promql/src/types/function.ts b/web/ui/module/codemirror-promql/src/types/function.ts index 890ef243e..4a2015534 100644 --- a/web/ui/module/codemirror-promql/src/types/function.ts +++ b/web/ui/module/codemirror-promql/src/types/function.ts @@ -15,16 +15,25 @@ import { Abs, Absent, AbsentOverTime, + Acos, + Acosh, + Asin, + Asinh, + Atan, + Atanh, AvgOverTime, Ceil, Changes, Clamp, ClampMax, ClampMin, + Cos, + Cosh, CountOverTime, DayOfMonth, DayOfWeek, DaysInMonth, + Deg, Delta, Deriv, Exp, @@ -45,20 +54,26 @@ import { MinOverTime, Minute, Month, + Pi, PredictLinear, PresentOverTime, QuantileOverTime, + Rad, Rate, Resets, Round, Scalar, Sgn, + Sin, + Sinh, Sort, SortDesc, Sqrt, StddevOverTime, StdvarOverTime, SumOverTime, + Tan, + Tanh, Time, Timestamp, Vector, @@ -101,6 +116,42 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Acos]: { + name: 'acos', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Acosh]: { + name: 'acosh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Asin]: { + name: 'asin', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Asinh]: { + name: 'asinh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Atan]: { + name: 'atan', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Atanh]: { + name: 'atanh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [AvgOverTime]: { name: 'avg_over_time', argTypes: [ValueType.matrix], @@ -137,6 +188,18 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Cos]: { + name: 'cos', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Cosh]: { + name: 'Cosh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [CountOverTime]: { name: 'count_over_time', argTypes: [ValueType.matrix], @@ -161,6 +224,12 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 1, returnType: ValueType.vector, }, + [Deg]: { + name: 'deg', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [Delta]: { name: 'delta', argTypes: [ValueType.matrix], @@ -281,6 +350,12 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 1, returnType: ValueType.vector, }, + [Pi]: { + name: 'pi', + argTypes: [], + variadic: 0, + returnType: ValueType.vector, + }, [PredictLinear]: { name: 'predict_linear', argTypes: [ValueType.matrix, ValueType.scalar], @@ -299,6 +374,12 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Rad]: { + name: 'rad', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [Rate]: { name: 'rate', argTypes: [ValueType.matrix], @@ -329,6 +410,18 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Sin]: { + name: 'sin', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Sinh]: { + name: 'Sinh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [Sort]: { name: 'sort', argTypes: [ValueType.vector], @@ -365,6 +458,18 @@ const promqlFunctions: { [key: number]: PromQLFunction } = { variadic: 0, returnType: ValueType.vector, }, + [Tan]: { + name: 'tan', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, + [Tanh]: { + name: 'tanh', + argTypes: [ValueType.vector], + variadic: 0, + returnType: ValueType.vector, + }, [Time]: { name: 'time', argTypes: [],