From 6b9a20bdb657a9de1981c1bcc156db4a97b210ad Mon Sep 17 00:00:00 2001 From: Arunprasad Rajkumar Date: Tue, 11 Oct 2022 18:25:35 +0530 Subject: [PATCH] Avoid using `total` suffix for gauge metrics and apply rate for counters Latest mixtool linter which relies on grafana-linter pkg is failing when gauge metrics with name ending with `total`[1]. [1] https://github.com/grafana/dashboard-linter/blob/44d415fb6bdc4d8e6585e514c448174d4de1ff02/lint/rule_target_counter_agg.go#L30 Signed-off-by: Arunprasad Rajkumar --- docs/mixin/.lint | 7 ------- docs/mixin/dashboards/promscale.json | 6 +++--- pkg/pgmodel/metrics/database/metrics.go | 4 ++-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/docs/mixin/.lint b/docs/mixin/.lint index 581418898b..5c737bd1f3 100644 --- a/docs/mixin/.lint +++ b/docs/mixin/.lint @@ -10,10 +10,3 @@ exclusions: template-datasource-rule: target-counter-agg-rule: reason: "disabled for promscale_sql_database_worker_maintenance_job_locks_total, promscale_sql_database_worker_maintenance_job_long_running_total. This metric should be not have total due to naming conventions as its a gauge, not a counter" - entries: - - dashboard: Promscale - panel: Long running maintenance queries by job type - - dashboard: Promscale - panel: Long running maintenance queries by wait event - - dashboard: Promscale - panel: Locks held by maintenance jobs by lock mode diff --git a/docs/mixin/dashboards/promscale.json b/docs/mixin/dashboards/promscale.json index ac538460bd..0a2d2bdebe 100644 --- a/docs/mixin/dashboards/promscale.json +++ b/docs/mixin/dashboards/promscale.json @@ -2370,7 +2370,7 @@ }, "editorMode": "code", "exemplar": false, - "expr": "max(promscale_sql_database_worker_maintenance_job_long_running_total{namespace=~\"$namespace\"})", + "expr": "max(promscale_sql_database_worker_maintenance_job_long_running{namespace=~\"$namespace\"})", "interval": "", "legendFormat": "total", "range": true, @@ -2918,7 +2918,7 @@ }, "editorMode": "code", "exemplar": false, - "expr": "max(promscale_sql_database_worker_maintenance_job_long_running_total{namespace=~\"$namespace\"})", + "expr": "max(promscale_sql_database_worker_maintenance_job_long_running{namespace=~\"$namespace\"})", "interval": "", "legendFormat": "total", "range": true, @@ -3094,7 +3094,7 @@ }, "editorMode": "code", "exemplar": false, - "expr": "max(promscale_sql_database_worker_maintenance_job_locks_total{namespace=~\"$namespace\"})", + "expr": "max(promscale_sql_database_worker_maintenance_job_locks{namespace=~\"$namespace\"})", "interval": "", "legendFormat": "total", "range": true, diff --git a/pkg/pgmodel/metrics/database/metrics.go b/pkg/pgmodel/metrics/database/metrics.go index e0c78d9c70..d59dbfaaea 100644 --- a/pkg/pgmodel/metrics/database/metrics.go +++ b/pkg/pgmodel/metrics/database/metrics.go @@ -249,7 +249,7 @@ var metrics = []metricQueryWrap{ prometheus.GaugeOpts{ Namespace: util.PromNamespace, Subsystem: "sql_database", - Name: "worker_maintenance_job_locks_total", + Name: "worker_maintenance_job_locks", Help: "Number of locks held by Promscale maintenance workers.", }, ), @@ -326,7 +326,7 @@ var metrics = []metricQueryWrap{ prometheus.GaugeOpts{ Namespace: util.PromNamespace, Subsystem: "sql_database", - Name: "worker_maintenance_job_long_running_total", + Name: "worker_maintenance_job_long_running", Help: "Number of Promscale maintenance workers executing long running queries.", }, ),