Skip to content

Commit 60d258b

Browse files
author
Mattia Eleuteri
committed
fix(monitoring): harden VM dashboard variables, queries, and units
- console-logs.json: Replace textbox namespace/vm variables with query-based variables to prevent wildcard cross-tenant data leaks - virtual-machines.json: Wrap net_rx, net_tx, iops_r, iops_w table queries with sum by (name)(...) to avoid duplicate series - virtual-machines.json: Change CPU panels unit from percentunit to short since rate(cpu_usage_seconds_total) returns cores, not percent Signed-off-by: Mattia Eleuteri <[email protected]>
1 parent 96cd231 commit 60d258b

2 files changed

Lines changed: 36 additions & 18 deletions

File tree

‎dashboards/vm/console-logs.json‎

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,43 @@
1818
"query": "victoriametrics-logs-datasource",
1919
"current": {}
2020
},
21+
{
22+
"name": "ds_prom",
23+
"label": "Prometheus",
24+
"type": "datasource",
25+
"query": "prometheus",
26+
"current": {}
27+
},
2128
{
2229
"name": "namespace",
2330
"label": "Namespace",
24-
"type": "textbox",
25-
"current": {
26-
"text": "*",
27-
"value": "*"
31+
"type": "query",
32+
"datasource": {
33+
"type": "prometheus",
34+
"uid": "${ds_prom}"
2835
},
29-
"description": "Kubernetes namespace filter (supports wildcards, e.g. tenant-* or *)"
36+
"query": "label_values(kubevirt_vmi_memory_available_bytes, namespace)",
37+
"multi": false,
38+
"includeAll": false,
39+
"current": {},
40+
"sort": 1
3041
},
3142
{
3243
"name": "vm",
3344
"label": "VM",
34-
"type": "textbox",
45+
"type": "query",
46+
"datasource": {
47+
"type": "prometheus",
48+
"uid": "${ds_prom}"
49+
},
50+
"query": "label_values(kubevirt_vmi_memory_available_bytes{namespace=\"$namespace\"}, name)",
51+
"multi": true,
52+
"includeAll": true,
3553
"current": {
36-
"text": "*",
37-
"value": "*"
54+
"text": "All",
55+
"value": "$__all"
3856
},
39-
"description": "VM name filter (supports wildcards, e.g. node-* or *)"
57+
"sort": 1
4058
}
4159
]
4260
},

‎dashboards/vm/virtual-machines.json‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@
131131
"options": { "colorMode": "value", "graphMode": "area", "textMode": "value" },
132132
"fieldConfig": {
133133
"defaults": {
134-
"unit": "percentunit",
135-
"decimals": 1,
134+
"unit": "short",
135+
"decimals": 2,
136136
"thresholds": {
137137
"steps": [
138138
{ "color": "green", "value": null },
@@ -192,28 +192,28 @@
192192
"instant": true
193193
},
194194
{
195-
"expr": "rate(kubevirt_vmi_network_receive_bytes_total{namespace=\"$namespace\", name=~\"$vm\"}[$__rate_interval])",
195+
"expr": "sum by (name)(rate(kubevirt_vmi_network_receive_bytes_total{namespace=\"$namespace\", name=~\"$vm\"}[$__rate_interval]))",
196196
"legendFormat": "{{ name }}",
197197
"refId": "net_rx",
198198
"format": "table",
199199
"instant": true
200200
},
201201
{
202-
"expr": "rate(kubevirt_vmi_network_transmit_bytes_total{namespace=\"$namespace\", name=~\"$vm\"}[$__rate_interval])",
202+
"expr": "sum by (name)(rate(kubevirt_vmi_network_transmit_bytes_total{namespace=\"$namespace\", name=~\"$vm\"}[$__rate_interval]))",
203203
"legendFormat": "{{ name }}",
204204
"refId": "net_tx",
205205
"format": "table",
206206
"instant": true
207207
},
208208
{
209-
"expr": "rate(kubevirt_vmi_storage_iops_read_total{namespace=\"$namespace\", name=~\"$vm\", drive!=\"cloudinitdisk\"}[$__rate_interval])",
209+
"expr": "sum by (name)(rate(kubevirt_vmi_storage_iops_read_total{namespace=\"$namespace\", name=~\"$vm\", drive!=\"cloudinitdisk\"}[$__rate_interval]))",
210210
"legendFormat": "{{ name }}",
211211
"refId": "iops_r",
212212
"format": "table",
213213
"instant": true
214214
},
215215
{
216-
"expr": "rate(kubevirt_vmi_storage_iops_write_total{namespace=\"$namespace\", name=~\"$vm\", drive!=\"cloudinitdisk\"}[$__rate_interval])",
216+
"expr": "sum by (name)(rate(kubevirt_vmi_storage_iops_write_total{namespace=\"$namespace\", name=~\"$vm\", drive!=\"cloudinitdisk\"}[$__rate_interval]))",
217217
"legendFormat": "{{ name }}",
218218
"refId": "iops_w",
219219
"format": "table",
@@ -277,7 +277,7 @@
277277
{
278278
"matcher": { "id": "byName", "options": "CPU" },
279279
"properties": [
280-
{ "id": "unit", "value": "percentunit" },
280+
{ "id": "unit", "value": "short" },
281281
{ "id": "decimals", "value": 1 },
282282
{
283283
"id": "thresholds",
@@ -385,7 +385,7 @@
385385
],
386386
"fieldConfig": {
387387
"defaults": {
388-
"unit": "percentunit",
388+
"unit": "short",
389389
"custom": { "fillOpacity": 10, "lineWidth": 1, "showPoints": "never" }
390390
}
391391
}
@@ -408,7 +408,7 @@
408408
],
409409
"fieldConfig": {
410410
"defaults": {
411-
"unit": "percentunit",
411+
"unit": "short",
412412
"custom": { "fillOpacity": 10, "lineWidth": 1, "showPoints": "never" }
413413
}
414414
}

0 commit comments

Comments
 (0)