Skip to content

Commit c29b27c

Browse files
authored
Fix interval template for increase/delta functions. (#1449)
* Fix interval template for increase/delta functions. * Fix
1 parent c014522 commit c29b27c

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

common-lib/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 0.3.4
2+
- [Signal] Fix interval template for increase/delta functions.
3+
14
# 0.3.3
25
- [Signal] add `withQuantile(quantile=0.95)` to histogram signals.
36

common-lib/common/signal/base.libsonnet

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
230230
],
231231
)
232232
else {}),
233-
234233
//Return query
235234
asPanelExpression():
236235
self.combineUniqueExpressions(
@@ -252,16 +251,18 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
252251
if source.infoLabel != null then [source.infoLabel]
253252
else []
254253
);
255-
local vars = this.vars { agg: std.join(',', aggLabels) };
256254
signalUtils.wrapExpr(
257255
type,
258256
source.expr,
259257
exprWrappers=std.get(source, 'exprWrappers', default=[]),
260258
q=std.get(source, 'quantile', default=0.95),
261259
aggLevel=aggLevel,
262260
rangeFunction=source.rangeFunction,
261+
alertRule=false,
263262
).applyFunctions()
264-
% vars
263+
% this.vars {
264+
agg: std.join(',', aggLabels),
265+
}
265266
for source in this.sourceMaps
266267
]
267268
),
@@ -278,6 +279,8 @@ local xtd = import 'github.com/jsonnet-libs/xtd/main.libsonnet';
278279
q=std.get(source, 'quantile', default=0.95),
279280
aggLevel='none',
280281
rangeFunction=source.rangeFunction,
282+
// ensure that interval doesn't have Grafana dashboard dynamic intervals:
283+
alertRule=true,
281284
).applyFunctions()
282285
% this.vars
283286
{ // ensure that interval doesn't have Grafana dashboard dynamic intervals:

common-lib/common/signal/utils.libsonnet

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
wrapExpr(type, expr, exprWrappers=[], q=0.95, aggLevel, rangeFunction): {
2+
wrapExpr(type, expr, exprWrappers=[], q=0.95, aggLevel, rangeFunction, alertRule): {
33

44
// additional templates to wrap base expression
55
functionTemplates::
@@ -22,7 +22,10 @@
2222
expr: if type == 'counter' then
2323
(
2424
// for increase/delta/idelta - must be $__interval with negative offset for proper Total calculations, else use default from init function.
25-
local interval = if (rangeFunction == 'idelta' || rangeFunction == 'delta' || rangeFunction == 'increase') then '[$__interval:] offset -$__interval' else '[%(interval)s]';
25+
local interval =
26+
if (rangeFunction == 'idelta' || rangeFunction == 'delta' || rangeFunction == 'increase') then
27+
(if alertRule then '[%(interval)s:] offset -%(interval)s' else '[$__interval:] offset -$__interval')
28+
else '[%(interval)s]';
2629
local baseExpr = rangeFunction + '(' + expr + interval + ')';
2730
baseExpr
2831
)

0 commit comments

Comments
 (0)