mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-17 01:59:04 +02:00
mixin: fix NaN columns and doubled counts on the Updates dashboard (#2703)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -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' } },
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user