Skip to content

utils: allow defining native histogram recording rule #1156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2024
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