From 2153e5178e5a388208cd587c9bc25de9c0bad389 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Otto=20Kr=C3=B6pke?= Date: Mon, 12 Oct 2026 22:44:30 +0200 Subject: [PATCH] mixin: fix NaN columns and doubled counts on the Updates dashboard (#2703) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan-Otto Kröpke --- contrib/mixin/dashboards/updates.libsonnet | 11 ++++- dashboard/windows-exporter-dashboard.json | 48 ++++++++++++++-------- dashboard/windows-exporter-updates.json | 48 ++++++++++++++-------- 3 files changed, 71 insertions(+), 36 deletions(-) diff --git a/contrib/mixin/dashboards/updates.libsonnet b/contrib/mixin/dashboards/updates.libsonnet index ef4b6fef..e5685cdb 100644 --- a/contrib/mixin/dashboards/updates.libsonnet +++ b/contrib/mixin/dashboards/updates.libsonnet @@ -2,7 +2,8 @@ local b = import 'builders.libsonnet'; local metric(name, labels='') = 'windows_update_' + name + '{job=~"$job", instance="$instance"' + (if labels == '' then '' else ', ' + labels) + '}'; local requirement = ' Requires the update collector, which is not enabled by default. The collector queries Windows Update in the background, every 6 hours by default.'; // Counts fall back to 0 only while the collector reports, so a missing collector shows no data. -local pending(labels) = 'count(' + metric('pending_info', labels) + ') or (0 * ' + metric('scrape_timestamp_seconds') + ')'; +// The fallback is aggregated too: count() has no labels, so a fallback with labels would be a second series. +local pending(labels) = 'count(' + metric('pending_info', labels) + ') or (0 * count(' + metric('scrape_timestamp_seconds') + '))'; local days(n) = n * 86400; function(on) @@ -43,9 +44,15 @@ function(on) }, }, }]) - + b.panel.withDefaults({ unit: 'dateTimeFromNow', mappings: [{ type: 'value', options: { '0': { index: 0, text: 'unknown' } } }] }) + b.panel.withOptions({ sortBy: [{ desc: false, displayName: 'Published' }] }) + // The date unit only fits the Published column. Set as a default, it also turns the label columns into NaN. + b.panel.withOverrides([{ + matcher: { id: 'byName', options: 'Published' }, + properties: [ + { id: 'unit', value: 'dateTimeFromNow' }, + { id: 'mappings', value: [{ type: 'value', options: { '0': { index: 0, text: 'unknown' } } }] }, + ], + }, { matcher: { id: 'byName', options: 'Severity' }, properties: [ { id: 'color', value: { fixedColor: 'text', mode: 'fixed' } }, diff --git a/dashboard/windows-exporter-dashboard.json b/dashboard/windows-exporter-dashboard.json index 88f08910..40d8dfe2 100644 --- a/dashboard/windows-exporter-dashboard.json +++ b/dashboard/windows-exporter-dashboard.json @@ -12711,7 +12711,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\"}) or (0 * windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"})", + "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\"}) or (0 * count(windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -12796,7 +12796,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", severity=\"Critical\"}) or (0 * windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"})", + "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", severity=\"Critical\"}) or (0 * count(windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -12884,7 +12884,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", severity=\"Important\"}) or (0 * windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"})", + "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", severity=\"Important\"}) or (0 * count(windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -12972,7 +12972,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", deployment_action=\"optional_installation\"}) or (0 * windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"})", + "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", deployment_action=\"optional_installation\"}) or (0 * count(windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -13307,17 +13307,6 @@ "inspect": false, "minWidth": 60 }, - "mappings": [ - { - "options": { - "0": { - "index": 0, - "text": "unknown" - } - }, - "type": "value" - } - ], "thresholds": { "mode": "absolute", "steps": [ @@ -13326,10 +13315,35 @@ "value": null } ] - }, - "unit": "dateTimeFromNow" + } }, "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Published" + }, + "properties": [ + { + "id": "unit", + "value": "dateTimeFromNow" + }, + { + "id": "mappings", + "value": [ + { + "options": { + "0": { + "index": 0, + "text": "unknown" + } + }, + "type": "value" + } + ] + } + ] + }, { "matcher": { "id": "byName", diff --git a/dashboard/windows-exporter-updates.json b/dashboard/windows-exporter-updates.json index b3c7a9f3..0b8e1eef 100644 --- a/dashboard/windows-exporter-updates.json +++ b/dashboard/windows-exporter-updates.json @@ -78,7 +78,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\"}) or (0 * windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"})", + "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\"}) or (0 * count(windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -163,7 +163,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", severity=\"Critical\"}) or (0 * windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"})", + "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", severity=\"Critical\"}) or (0 * count(windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -251,7 +251,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", severity=\"Important\"}) or (0 * windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"})", + "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", severity=\"Important\"}) or (0 * count(windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -339,7 +339,7 @@ "kind": "DataQuery", "spec": { "editorMode": "code", - "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", deployment_action=\"optional_installation\"}) or (0 * windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"})", + "expr": "count(windows_update_pending_info{job=~\"$job\", instance=\"$instance\", deployment_action=\"optional_installation\"}) or (0 * count(windows_update_scrape_timestamp_seconds{job=~\"$job\", instance=\"$instance\"}))", "instant": false, "legendFormat": "__auto", "range": true @@ -674,17 +674,6 @@ "inspect": false, "minWidth": 60 }, - "mappings": [ - { - "options": { - "0": { - "index": 0, - "text": "unknown" - } - }, - "type": "value" - } - ], "thresholds": { "mode": "absolute", "steps": [ @@ -693,10 +682,35 @@ "value": null } ] - }, - "unit": "dateTimeFromNow" + } }, "overrides": [ + { + "matcher": { + "id": "byName", + "options": "Published" + }, + "properties": [ + { + "id": "unit", + "value": "dateTimeFromNow" + }, + { + "id": "mappings", + "value": [ + { + "options": { + "0": { + "index": 0, + "text": "unknown" + } + }, + "type": "value" + } + ] + } + ] + }, { "matcher": { "id": "byName",