Skip to content

Commit 96e5a94

Browse files
committed
promql: rename holt_winters to double_exponential_smoothing
Signed-off-by: Jan Fajerski <[email protected]>
1 parent 15cea39 commit 96e5a94

File tree

13 files changed

+117
-100
lines changed

13 files changed

+117
-100
lines changed

docs/querying/functions.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -380,17 +380,22 @@ do not show up in the returned vector.
380380
Similarly, `histogram_stdvar(v instant-vector)` returns the estimated standard
381381
variance of observations in a native histogram.
382382

383-
## `holt_winters()`
383+
## `double_exponential_smoothing()`
384384

385385
**This function has to be enabled via the [feature flag](../feature_flags.md#experimental-promql-functions) `--enable-feature=promql-experimental-functions`.**
386386

387-
`holt_winters(v range-vector, sf scalar, tf scalar)` produces a smoothed value
387+
`double_exponential_smoothing(v range-vector, sf scalar, tf scalar)` produces a smoothed value
388388
for time series based on the range in `v`. The lower the smoothing factor `sf`,
389389
the more importance is given to old data. The higher the trend factor `tf`, the
390390
more trends in the data is considered. Both `sf` and `tf` must be between 0 and
391391
1.
392+
For additional details, refer to [NIST Engineering Statistics Handbook](https://www.itl.nist.gov/div898/handbook/pmc/section4/pmc433.htm).
393+
In Prometheus V2 this function was called `holt_winters`. This caused confusion
394+
since the Holt-Winters method usually refers to triple exponential smoothing.
395+
Double exponential smoothing as implemented here is also referred to as "Holt
396+
Linear".
392397

393-
`holt_winters` should only be used with gauges.
398+
`double_exponential_smoothing` should only be used with gauges.
394399

395400
## `hour()`
396401

promql/bench_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func rangeQueryCases() []benchCase {
117117
},
118118
// Holt-Winters and long ranges.
119119
{
120-
expr: "holt_winters(a_X[1d], 0.3, 0.3)",
120+
expr: "double_exponential_smoothing(a_X[1d], 0.3, 0.3)",
121121
},
122122
{
123123
expr: "changes(a_X[1d])",

promql/functions.go

+77-77
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func calcTrendValue(i int, tf, s0, s1, b float64) float64 {
350350
// data. A lower smoothing factor increases the influence of historical data. The trend factor (0 < tf < 1) affects
351351
// how trends in historical data will affect the current data. A higher trend factor increases the influence.
352352
// of trends. Algorithm taken from https://en.wikipedia.org/wiki/Exponential_smoothing titled: "Double exponential smoothing".
353-
func funcHoltWinters(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) (Vector, annotations.Annotations) {
353+
func funcDoubleExponentialSmoothing(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper) (Vector, annotations.Annotations) {
354354
samples := vals[0].(Matrix)[0]
355355

356356
// The smoothing factor argument.
@@ -1657,82 +1657,82 @@ func funcYear(vals []parser.Value, args parser.Expressions, enh *EvalNodeHelper)
16571657

16581658
// FunctionCalls is a list of all functions supported by PromQL, including their types.
16591659
var FunctionCalls = map[string]FunctionCall{
1660-
"abs": funcAbs,
1661-
"absent": funcAbsent,
1662-
"absent_over_time": funcAbsentOverTime,
1663-
"acos": funcAcos,
1664-
"acosh": funcAcosh,
1665-
"asin": funcAsin,
1666-
"asinh": funcAsinh,
1667-
"atan": funcAtan,
1668-
"atanh": funcAtanh,
1669-
"avg_over_time": funcAvgOverTime,
1670-
"ceil": funcCeil,
1671-
"changes": funcChanges,
1672-
"clamp": funcClamp,
1673-
"clamp_max": funcClampMax,
1674-
"clamp_min": funcClampMin,
1675-
"cos": funcCos,
1676-
"cosh": funcCosh,
1677-
"count_over_time": funcCountOverTime,
1678-
"days_in_month": funcDaysInMonth,
1679-
"day_of_month": funcDayOfMonth,
1680-
"day_of_week": funcDayOfWeek,
1681-
"day_of_year": funcDayOfYear,
1682-
"deg": funcDeg,
1683-
"delta": funcDelta,
1684-
"deriv": funcDeriv,
1685-
"exp": funcExp,
1686-
"floor": funcFloor,
1687-
"histogram_avg": funcHistogramAvg,
1688-
"histogram_count": funcHistogramCount,
1689-
"histogram_fraction": funcHistogramFraction,
1690-
"histogram_quantile": funcHistogramQuantile,
1691-
"histogram_sum": funcHistogramSum,
1692-
"histogram_stddev": funcHistogramStdDev,
1693-
"histogram_stdvar": funcHistogramStdVar,
1694-
"holt_winters": funcHoltWinters,
1695-
"hour": funcHour,
1696-
"idelta": funcIdelta,
1697-
"increase": funcIncrease,
1698-
"irate": funcIrate,
1699-
"label_replace": funcLabelReplace,
1700-
"label_join": funcLabelJoin,
1701-
"ln": funcLn,
1702-
"log10": funcLog10,
1703-
"log2": funcLog2,
1704-
"last_over_time": funcLastOverTime,
1705-
"mad_over_time": funcMadOverTime,
1706-
"max_over_time": funcMaxOverTime,
1707-
"min_over_time": funcMinOverTime,
1708-
"minute": funcMinute,
1709-
"month": funcMonth,
1710-
"pi": funcPi,
1711-
"predict_linear": funcPredictLinear,
1712-
"present_over_time": funcPresentOverTime,
1713-
"quantile_over_time": funcQuantileOverTime,
1714-
"rad": funcRad,
1715-
"rate": funcRate,
1716-
"resets": funcResets,
1717-
"round": funcRound,
1718-
"scalar": funcScalar,
1719-
"sgn": funcSgn,
1720-
"sin": funcSin,
1721-
"sinh": funcSinh,
1722-
"sort": funcSort,
1723-
"sort_desc": funcSortDesc,
1724-
"sort_by_label": funcSortByLabel,
1725-
"sort_by_label_desc": funcSortByLabelDesc,
1726-
"sqrt": funcSqrt,
1727-
"stddev_over_time": funcStddevOverTime,
1728-
"stdvar_over_time": funcStdvarOverTime,
1729-
"sum_over_time": funcSumOverTime,
1730-
"tan": funcTan,
1731-
"tanh": funcTanh,
1732-
"time": funcTime,
1733-
"timestamp": funcTimestamp,
1734-
"vector": funcVector,
1735-
"year": funcYear,
1660+
"abs": funcAbs,
1661+
"absent": funcAbsent,
1662+
"absent_over_time": funcAbsentOverTime,
1663+
"acos": funcAcos,
1664+
"acosh": funcAcosh,
1665+
"asin": funcAsin,
1666+
"asinh": funcAsinh,
1667+
"atan": funcAtan,
1668+
"atanh": funcAtanh,
1669+
"avg_over_time": funcAvgOverTime,
1670+
"ceil": funcCeil,
1671+
"changes": funcChanges,
1672+
"clamp": funcClamp,
1673+
"clamp_max": funcClampMax,
1674+
"clamp_min": funcClampMin,
1675+
"cos": funcCos,
1676+
"cosh": funcCosh,
1677+
"count_over_time": funcCountOverTime,
1678+
"days_in_month": funcDaysInMonth,
1679+
"day_of_month": funcDayOfMonth,
1680+
"day_of_week": funcDayOfWeek,
1681+
"day_of_year": funcDayOfYear,
1682+
"deg": funcDeg,
1683+
"delta": funcDelta,
1684+
"deriv": funcDeriv,
1685+
"exp": funcExp,
1686+
"floor": funcFloor,
1687+
"histogram_avg": funcHistogramAvg,
1688+
"histogram_count": funcHistogramCount,
1689+
"histogram_fraction": funcHistogramFraction,
1690+
"histogram_quantile": funcHistogramQuantile,
1691+
"histogram_sum": funcHistogramSum,
1692+
"histogram_stddev": funcHistogramStdDev,
1693+
"histogram_stdvar": funcHistogramStdVar,
1694+
"double_exponential_smoothing": funcDoubleExponentialSmoothing,
1695+
"hour": funcHour,
1696+
"idelta": funcIdelta,
1697+
"increase": funcIncrease,
1698+
"irate": funcIrate,
1699+
"label_replace": funcLabelReplace,
1700+
"label_join": funcLabelJoin,
1701+
"ln": funcLn,
1702+
"log10": funcLog10,
1703+
"log2": funcLog2,
1704+
"last_over_time": funcLastOverTime,
1705+
"mad_over_time": funcMadOverTime,
1706+
"max_over_time": funcMaxOverTime,
1707+
"min_over_time": funcMinOverTime,
1708+
"minute": funcMinute,
1709+
"month": funcMonth,
1710+
"pi": funcPi,
1711+
"predict_linear": funcPredictLinear,
1712+
"present_over_time": funcPresentOverTime,
1713+
"quantile_over_time": funcQuantileOverTime,
1714+
"rad": funcRad,
1715+
"rate": funcRate,
1716+
"resets": funcResets,
1717+
"round": funcRound,
1718+
"scalar": funcScalar,
1719+
"sgn": funcSgn,
1720+
"sin": funcSin,
1721+
"sinh": funcSinh,
1722+
"sort": funcSort,
1723+
"sort_desc": funcSortDesc,
1724+
"sort_by_label": funcSortByLabel,
1725+
"sort_by_label_desc": funcSortByLabelDesc,
1726+
"sqrt": funcSqrt,
1727+
"stddev_over_time": funcStddevOverTime,
1728+
"stdvar_over_time": funcStdvarOverTime,
1729+
"sum_over_time": funcSumOverTime,
1730+
"tan": funcTan,
1731+
"tanh": funcTanh,
1732+
"time": funcTime,
1733+
"timestamp": funcTimestamp,
1734+
"vector": funcVector,
1735+
"year": funcYear,
17361736
}
17371737

17381738
// AtModifierUnsafeFunctions are the functions whose result

promql/parser/functions.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ var Functions = map[string]*Function{
202202
ArgTypes: []ValueType{ValueTypeScalar, ValueTypeVector},
203203
ReturnType: ValueTypeVector,
204204
},
205-
"holt_winters": {
206-
Name: "holt_winters",
205+
"double_exponential_smoothing": {
206+
Name: "double_exponential_smoothing",
207207
ArgTypes: []ValueType{ValueTypeMatrix, ValueTypeScalar, ValueTypeScalar},
208208
ReturnType: ValueTypeVector,
209209
Experimental: true,

promql/promqltest/testdata/functions.test

+3-3
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ eval_ordered instant at 50m sort_by_label(node_uname_info, "release")
651651
node_uname_info{job="node_exporter", instance="4m5", release="1.11.3"} 100
652652
node_uname_info{job="node_exporter", instance="4m1000", release="1.111.3"} 100
653653

654-
# Tests for holt_winters
654+
# Tests for double_exponential_smoothing
655655
clear
656656

657657
# positive trends
@@ -661,7 +661,7 @@ load 10s
661661
http_requests{job="api-server", instance="0", group="canary"} 0+30x1000 300+80x1000
662662
http_requests{job="api-server", instance="1", group="canary"} 0+40x2000
663663

664-
eval instant at 8000s holt_winters(http_requests[1m], 0.01, 0.1)
664+
eval instant at 8000s double_exponential_smoothing(http_requests[1m], 0.01, 0.1)
665665
{job="api-server", instance="0", group="production"} 8000
666666
{job="api-server", instance="1", group="production"} 16000
667667
{job="api-server", instance="0", group="canary"} 24000
@@ -675,7 +675,7 @@ load 10s
675675
http_requests{job="api-server", instance="0", group="canary"} 0+30x1000 300-80x1000
676676
http_requests{job="api-server", instance="1", group="canary"} 0-40x1000 0+40x1000
677677

678-
eval instant at 8000s holt_winters(http_requests[1m], 0.01, 0.1)
678+
eval instant at 8000s double_exponential_smoothing(http_requests[1m], 0.01, 0.1)
679679
{job="api-server", instance="0", group="production"} 0
680680
{job="api-server", instance="1", group="production"} -16000
681681
{job="api-server", instance="0", group="canary"} 24000

ui-commits

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dfec29d8e Fix border color for target pools with one target that is failing
2+
65743bf9b ui: drop template readme
3+
a7c1a951d Add general Mantine overrides CSS file
4+
0757fbbec Make sure that alert element table headers are not wrapped
5+
0180cf31a Factor out common icon and card styles
6+
50af7d589 Fix tree line drawing by using a callback ref
7+
ac01dc903 Explain, vector-to-vector: Do not compute results for set operators
8+
9b0dc68d0 PromQL explain view: Support set operators
9+
57898c792 Refactor and fix time formatting functions, add tests
10+
091fc403c Fiddle with targets table styles to try and improve things a bit
11+
a1908df92 Don't wrap action buttons below metric name in metrics explorer
12+
ac5377873 mantine UI: Distinguish between Not Ready and Stopping

web/ui/mantine-ui/src/promql/functionDocs.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -1277,17 +1277,17 @@ const funcDocs: Record<string, React.ReactNode> = {
12771277
</p>
12781278
</>
12791279
),
1280-
holt_winters: (
1280+
double_exponential_smoothing: (
12811281
<>
12821282
<p>
1283-
<code>holt_winters(v range-vector, sf scalar, tf scalar)</code> produces a smoothed value for time series based on
1283+
<code>double_exponential_smoothing(v range-vector, sf scalar, tf scalar)</code> produces a smoothed value for time series based on
12841284
the range in <code>v</code>. The lower the smoothing factor <code>sf</code>, the more importance is given to old
12851285
data. The higher the trend factor <code>tf</code>, the more trends in the data is considered. Both <code>sf</code>{' '}
12861286
and <code>tf</code> must be between 0 and 1.
12871287
</p>
12881288

12891289
<p>
1290-
<code>holt_winters</code> should only be used with gauges.
1290+
<code>double_exponential_smoothing</code> should only be used with gauges.
12911291
</p>
12921292
</>
12931293
),

web/ui/mantine-ui/src/promql/functionMeta.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const functionArgNames: Record<string, string[]> = {
1717
// exp: [],
1818
// floor: [],
1919
histogram_quantile: ['target quantile', 'histogram'],
20-
holt_winters: ['input series', 'smoothing factor', 'trend factor'],
20+
double_exponential_smoothing: ['input series', 'smoothing factor', 'trend factor'],
2121
hour: ['timestamp (default = vector(time()))'],
2222
// idelta: [],
2323
// increase: [],
@@ -68,7 +68,7 @@ export const functionDescriptions: Record<string, string> = {
6868
exp: 'calculate exponential function for input vector values',
6969
floor: 'round down values of input series to nearest integer',
7070
histogram_quantile: 'calculate quantiles from histogram buckets',
71-
holt_winters: 'calculate smoothed value of input series',
71+
double_exponential_smoothing: 'calculate smoothed value of input series',
7272
hour: 'return the hour of the day for provided timestamps',
7373
idelta: 'calculate the difference between the last two samples of a range vector (for counters)',
7474
increase: 'calculate the increase in value over a range of time (for counters)',

web/ui/mantine-ui/src/promql/functionSignatures.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export const functionSignatures: Record<string, Func> = {
6060
histogram_stddev: { name: 'histogram_stddev', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },
6161
histogram_stdvar: { name: 'histogram_stdvar', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },
6262
histogram_sum: { name: 'histogram_sum', argTypes: [valueType.vector], variadic: 0, returnType: valueType.vector },
63-
holt_winters: {
64-
name: 'holt_winters',
63+
double_exponential_smoothing: {
64+
name: 'double_exponential_smoothing',
6565
argTypes: [valueType.matrix, valueType.scalar, valueType.scalar],
6666
variadic: 0,
6767
returnType: valueType.vector,

web/ui/module/codemirror-promql/src/complete/promql.terms.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ export const functionIdentifierTerms = [
258258
type: 'function',
259259
},
260260
{
261-
label: 'holt_winters',
261+
label: 'double_exponential_smoothing',
262262
detail: 'function',
263263
info: 'Calculate smoothed value of input series',
264264
type: 'function',

web/ui/module/codemirror-promql/src/types/function.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import {
4646
HistogramStdDev,
4747
HistogramStdVar,
4848
HistogramSum,
49-
HoltWinters,
49+
DoubleExponentialSmoothing,
5050
Hour,
5151
Idelta,
5252
Increase,
@@ -312,8 +312,8 @@ const promqlFunctions: { [key: number]: PromQLFunction } = {
312312
variadic: 0,
313313
returnType: ValueType.vector,
314314
},
315-
[HoltWinters]: {
316-
name: 'holt_winters',
315+
[DoubleExponentialSmoothing]: {
316+
name: 'double_exponential_smoothing',
317317
argTypes: [ValueType.matrix, ValueType.scalar, ValueType.scalar],
318318
variadic: 0,
319319
returnType: ValueType.vector,

web/ui/module/lezer-promql/src/highlight.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const promQLHighLight = styleTags({
2020
NumberDurationLiteral: tags.number,
2121
NumberDurationLiteralInDurationContext: tags.number,
2222
Identifier: tags.variableName,
23-
'Abs Absent AbsentOverTime Acos Acosh Asin Asinh Atan Atanh AvgOverTime Ceil Changes Clamp ClampMax ClampMin Cos Cosh CountOverTime DaysInMonth DayOfMonth DayOfWeek DayOfYear Deg Delta Deriv Exp Floor HistogramAvg HistogramCount HistogramFraction HistogramQuantile HistogramSum 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 SortByLabel SortByLabelDesc Sqrt StddevOverTime StdvarOverTime SumOverTime Tan Tanh Time Timestamp Vector Year':
23+
'Abs Absent AbsentOverTime Acos Acosh Asin Asinh Atan Atanh AvgOverTime Ceil Changes Clamp ClampMax ClampMin Cos Cosh CountOverTime DaysInMonth DayOfMonth DayOfWeek DayOfYear Deg Delta Deriv Exp Floor HistogramAvg HistogramCount HistogramFraction HistogramQuantile HistogramSum DoubleExponentialSmoothing 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 SortByLabel SortByLabelDesc Sqrt StddevOverTime StdvarOverTime SumOverTime Tan Tanh Time Timestamp Vector Year':
2424
tags.function(tags.variableName),
2525
'Avg Bottomk Count Count_values Group LimitK LimitRatio Max Min Quantile Stddev Stdvar Sum Topk': tags.operatorKeyword,
2626
'By Without Bool On Ignoring GroupLeft GroupRight Offset Start End': tags.modifier,

web/ui/module/lezer-promql/src/promql.grammar

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ FunctionIdentifier {
141141
HistogramStdVar |
142142
HistogramSum |
143143
HistogramAvg |
144-
HoltWinters |
144+
DoubleExponentialSmoothing |
145145
Hour |
146146
Idelta |
147147
Increase |
@@ -388,7 +388,7 @@ NumberDurationLiteralInDurationContext {
388388
HistogramStdDev { condFn<"histogram_stddev"> }
389389
HistogramStdVar { condFn<"histogram_stdvar"> }
390390
HistogramSum { condFn<"histogram_sum"> }
391-
HoltWinters { condFn<"holt_winters"> }
391+
DoubleExponentialSmoothing { condFn<"double_exponential_smoothing"> }
392392
Hour { condFn<"hour"> }
393393
Idelta { condFn<"idelta"> }
394394
Increase { condFn<"increase"> }

0 commit comments

Comments
 (0)