From acb73dce0cfa88a797fa96fed815d1075fad85fc Mon Sep 17 00:00:00 2001 From: Daniil Polyakov Date: Mon, 3 Aug 2026 19:29:16 +0300 Subject: [PATCH] fix(dashboard_gen): use RATE_WINDOW in rate_per_min calculation --- monitoring/grafana/dashboards/sequencer.json | 8 ++++---- .../grafana/provisioning/datasources/prometheus.yml | 3 +++ tools/dashboard_gen/src/lib.rs | 11 +++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/monitoring/grafana/dashboards/sequencer.json b/monitoring/grafana/dashboards/sequencer.json index 85ee0b28..f9297c80 100644 --- a/monitoring/grafana/dashboards/sequencer.json +++ b/monitoring/grafana/dashboards/sequencer.json @@ -71,7 +71,7 @@ "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, - "expr": "rate(blocks_produced_total[1m]) * 60", + "expr": "rate(blocks_produced_total[$__rate_interval]) * 60", "legendFormat": "produced · blocks/min", "refId": "A" } @@ -327,19 +327,19 @@ "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, - "expr": "rate(submitted_transactions_total[1m]) * 60", + "expr": "rate(submitted_transactions_total[$__rate_interval]) * 60", "legendFormat": "submitted", "refId": "A" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, - "expr": "rate(before_mempool_failed_transactions_total[1m]) * 60", + "expr": "rate(before_mempool_failed_transactions_total[$__rate_interval]) * 60", "legendFormat": "failed · before mempool", "refId": "B" }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, - "expr": "rate(mempool_failed_transactions_total[1m]) * 60", + "expr": "rate(mempool_failed_transactions_total[$__rate_interval]) * 60", "legendFormat": "failed · in mempool", "refId": "C" } diff --git a/monitoring/grafana/provisioning/datasources/prometheus.yml b/monitoring/grafana/provisioning/datasources/prometheus.yml index 0b304bc9..9bf28c50 100644 --- a/monitoring/grafana/provisioning/datasources/prometheus.yml +++ b/monitoring/grafana/provisioning/datasources/prometheus.yml @@ -8,3 +8,6 @@ datasources: url: http://prometheus:9090 isDefault: true editable: true + jsonData: + # Must match prometheus.yml's `scrape_interval` + timeInterval: 5s diff --git a/tools/dashboard_gen/src/lib.rs b/tools/dashboard_gen/src/lib.rs index 350188a2..06104582 100644 --- a/tools/dashboard_gen/src/lib.rs +++ b/tools/dashboard_gen/src/lib.rs @@ -36,9 +36,10 @@ mod unit; /// than by a per-environment URL. pub const DATASOURCE_UID: &str = "prometheus"; -/// Window every histogram query rates over. `$__rate_interval` tracks the -/// panel's zoom, so a percentile covers the range you are actually looking at, -/// and an idle window yields no value rather than a zero. +/// Window every rate query — counter and histogram alike — rates over. +/// `$__rate_interval` tracks the panel's zoom, so the window always covers the +/// step Grafana samples at: a fixed one shorter than the step leaves gaps the +/// query never looks at, dropping events from the graph entirely. const RATE_WINDOW: &str = "$__rate_interval"; /// Dashboard variable holding the quantile every percentile query reads. @@ -578,7 +579,9 @@ pub fn avg(metric: &str) -> Target { /// A per-minute rate target for a counter metric. #[must_use] pub fn rate_per_min(metric: &str, legend: &str) -> Target { - Target::new(format!("rate({metric}[1m]) * 60")).legend(legend) + //`rate` is per-second whatever the window, so `* 60` is per-minute regardless of the panel's + //`rate` zoom. + Target::new(format!("rate({metric}[{RATE_WINDOW}]) * 60")).legend(legend) } const fn default_unit() -> Unit {