Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions mixin-utils/utils.libsonnet
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local g = import 'grafana-builder/grafana.libsonnet';

{
histogramRules(metric, labels, interval='1m')::
histogramRules(metric, labels, interval='1m', record_native=false)::
local vars = {
metric: metric,
labels_underscore: std.join('_', labels),
Expand Down Expand Up @@ -33,7 +33,18 @@ local g = import 'grafana-builder/grafana.libsonnet';
record: '%(labels_underscore)s:%(metric)s_count:sum_rate' % vars,
expr: 'sum(rate(%(metric)s_count[%(interval)s])) by (%(labels_comma)s)' % vars,
},
],
] + if record_native then [
// Native histogram rule, sum_rate contains the following information:
// - rate of sum,
// - rate of count,
// - rate of sum/count aka average,
// - rate of buckets,
// - implicitly the quantile information.
{
record: '%(labels_underscore)s:%(metric)s:sum_rate' % vars,
expr: 'sum(rate(%(metric)s[%(interval)s])) by (%(labels_comma)s)' % vars,
},
] else [],


// latencyRecordingRulePanel - build a latency panel for a recording rule.
Expand Down