Skip to content

Commit b7d0399

Browse files
committed
Sometimes you want to not specify the matcher, but you need the label in the recording rule name.
Signed-off-by: Tom Wilkie <[email protected]>
1 parent bb69541 commit b7d0399

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mixin-utils/utils.libsonnet

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,16 @@ local g = import 'grafana-builder/grafana.libsonnet';
106106
neq(label, value):: { label: label, op: '!=', value: value },
107107
re(label, value):: { label: label, op: '=~', value: value },
108108
nre(label, value):: { label: label, op: '!~', value: value },
109+
110+
// Use with latencyRecordingRulePanel to get the label in the metric name
111+
// but not in the selector.
112+
noop(label):: { label: label, op: 'nop' },
109113
},
110114

111115
toPrometheusSelector(selector)::
112116
local pairs = [
113117
'%(label)s%(op)s"%(value)s"' % matcher
114-
for matcher in selector
118+
for matcher in std.filter(function(matcher) matcher.op != 'nop', selector)
115119
];
116120
'{%s}' % std.join(', ', pairs),
117121
}

0 commit comments

Comments
 (0)