monitoring: force one-row value-only split panels

This commit is contained in:
Brad Stein 2026-04-13 04:51:00 -03:00
parent 3dd0bc875d
commit 0a28cf07c2
3 changed files with 895 additions and 210 deletions

View File

@ -1153,6 +1153,97 @@ def canvas_metric_grid_panel(
return panel
def canvas_two_metric_row_panel(
panel_id,
title,
grid,
*,
targets,
field_overrides=None,
links=None,
description=None,
metric_size=30,
color_fields=None,
thresholds=None,
):
"""Return a canvas panel with two values rendered side-by-side and no labels."""
if color_fields is None:
color_fields = [targets[0]["legendFormat"], targets[1]["legendFormat"]]
def metric_element(name, field, left, top, color_field):
return {
"type": "metric-value",
"name": name,
"constraint": {"horizontal": "left", "vertical": "top"},
"placement": {
"left": left,
"top": top,
"width": 146,
"height": 42,
},
"background": {"color": {"fixed": "transparent"}},
"border": {"color": {"fixed": "transparent"}},
"config": {
"align": "center",
"valign": "middle",
"size": metric_size,
"color": {"field": color_field, "fixed": "text"},
"text": {
"mode": "field",
"field": field,
"fixed": "",
},
},
"links": [],
}
panel = {
"id": panel_id,
"type": "canvas",
"title": title,
"datasource": PROM_DS,
"gridPos": grid,
"targets": targets,
"fieldConfig": {
"defaults": {
"mappings": [],
"thresholds": thresholds
or {
"mode": "absolute",
"steps": [
{"color": "rgba(115, 115, 115, 1)", "value": None},
{"color": "green", "value": 1},
],
},
"color": {"mode": "thresholds"},
},
"overrides": field_overrides or [],
},
"options": {
"inlineEditing": False,
"showAdvancedTypes": True,
"panZoom": False,
"infinitePan": False,
"root": {
"type": "frame",
"name": f"{title} frame",
"elements": [
metric_element("Cell 1", targets[0]["legendFormat"], 12, 38, color_fields[0]),
metric_element("Cell 2", targets[1]["legendFormat"], 168, 38, color_fields[1]),
],
"background": {"color": {"fixed": "transparent"}},
"border": {"color": {"fixed": "transparent"}},
},
},
}
if links:
panel["links"] = links
if description:
panel["description"] = description
return panel
def table_panel(
panel_id,
title,
@ -1739,18 +1830,11 @@ def build_overview():
],
}
panels.append(
stat_panel(
canvas_two_metric_row_panel(
40,
f"{ANANKE_UPS_DB_NAME} UPS Current",
None,
{"h": 2, "w": 6, "x": 0, "y": 7},
unit="none",
decimals=1,
text_mode="value",
orientation="horizontal",
wide_layout=True,
graph_mode="none",
value_size=30,
metric_size=30,
targets=[
{"refId": "A", "expr": ANANKE_UPS_DRAW_WATTS_DB, "legendFormat": "Draw", "instant": True},
{"refId": "B", "expr": ANANKE_UPS_RUNTIME_DB, "legendFormat": "Runtime", "instant": True},
@ -1763,18 +1847,11 @@ def build_overview():
)
)
panels.append(
stat_panel(
canvas_two_metric_row_panel(
144,
f"{ANANKE_UPS_TETHYS_NAME} UPS Current",
None,
{"h": 3, "w": 6, "x": 0, "y": 9},
unit="none",
decimals=1,
text_mode="value",
orientation="horizontal",
wide_layout=True,
graph_mode="none",
value_size=30,
metric_size=30,
targets=[
{"refId": "A", "expr": ANANKE_UPS_DRAW_WATTS_TETHYS, "legendFormat": "Draw", "instant": True},
{"refId": "B", "expr": ANANKE_UPS_RUNTIME_TETHYS, "legendFormat": "Runtime", "instant": True},
@ -1804,17 +1881,11 @@ def build_overview():
)
)
panels.append(
stat_panel(
canvas_two_metric_row_panel(
42,
"Current Enclosure Temperature",
None,
{"h": 3, "w": 6, "x": 0, "y": 12},
unit="none",
text_mode="value",
orientation="horizontal",
wide_layout=True,
graph_mode="none",
value_size=30,
metric_size=30,
targets=[
{"refId": "A", "expr": CLIMATE_TEMP_MAX, "legendFormat": "°C", "instant": True},
{"refId": "B", "expr": CLIMATE_TEMP_FAHRENHEIT_MAX, "legendFormat": "°F", "instant": True},
@ -1827,17 +1898,11 @@ def build_overview():
)
)
panels.append(
stat_panel(
canvas_two_metric_row_panel(
143,
"Current Enclosure Climate",
None,
{"h": 3, "w": 6, "x": 0, "y": 15},
unit="none",
text_mode="value",
orientation="horizontal",
wide_layout=True,
graph_mode="none",
value_size=30,
metric_size=30,
targets=[
{"refId": "A", "expr": CLIMATE_HUMIDITY_MAX, "legendFormat": "%RH", "instant": True},
{"refId": "B", "expr": CLIMATE_PRESSURE_CURRENT, "legendFormat": "kPa", "instant": True},

View File

@ -1072,7 +1072,7 @@
},
{
"id": 40,
"type": "stat",
"type": "canvas",
"title": "Pyrphoros UPS Current",
"datasource": {
"type": "prometheus",
@ -1100,9 +1100,6 @@
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
@ -1117,11 +1114,9 @@
}
]
},
"unit": "none",
"custom": {
"displayMode": "auto"
},
"decimals": 1
"color": {
"mode": "thresholds"
}
},
"overrides": [
{
@ -1151,21 +1146,103 @@
]
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"reduceOptions": {
"calcs": [
"lastNotNull"
"inlineEditing": false,
"showAdvancedTypes": true,
"panZoom": false,
"infinitePan": false,
"root": {
"type": "frame",
"name": "Pyrphoros UPS Current frame",
"elements": [
{
"type": "metric-value",
"name": "Cell 1",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 12,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "Draw",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "Draw",
"fixed": ""
}
},
"links": []
},
{
"type": "metric-value",
"name": "Cell 2",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 168,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "Runtime",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "Runtime",
"fixed": ""
}
},
"links": []
}
],
"fields": "",
"values": false
},
"textMode": "value",
"orientation": "horizontal",
"wideLayout": true,
"text": {
"valueSize": 30
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
}
}
},
"links": [
@ -1178,7 +1255,7 @@
},
{
"id": 144,
"type": "stat",
"type": "canvas",
"title": "Statera UPS Current",
"datasource": {
"type": "prometheus",
@ -1206,9 +1283,6 @@
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
@ -1223,11 +1297,9 @@
}
]
},
"unit": "none",
"custom": {
"displayMode": "auto"
},
"decimals": 1
"color": {
"mode": "thresholds"
}
},
"overrides": [
{
@ -1257,21 +1329,103 @@
]
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"reduceOptions": {
"calcs": [
"lastNotNull"
"inlineEditing": false,
"showAdvancedTypes": true,
"panZoom": false,
"infinitePan": false,
"root": {
"type": "frame",
"name": "Statera UPS Current frame",
"elements": [
{
"type": "metric-value",
"name": "Cell 1",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 12,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "Draw",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "Draw",
"fixed": ""
}
},
"links": []
},
{
"type": "metric-value",
"name": "Cell 2",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 168,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "Runtime",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "Runtime",
"fixed": ""
}
},
"links": []
}
],
"fields": "",
"values": false
},
"textMode": "value",
"orientation": "horizontal",
"wideLayout": true,
"text": {
"valueSize": 30
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
}
}
},
"links": [
@ -1338,7 +1492,7 @@
},
{
"id": 42,
"type": "stat",
"type": "canvas",
"title": "Current Enclosure Temperature",
"datasource": {
"type": "prometheus",
@ -1366,9 +1520,6 @@
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
@ -1383,9 +1534,8 @@
}
]
},
"unit": "none",
"custom": {
"displayMode": "auto"
"color": {
"mode": "thresholds"
}
},
"overrides": [
@ -1416,21 +1566,103 @@
]
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"reduceOptions": {
"calcs": [
"lastNotNull"
"inlineEditing": false,
"showAdvancedTypes": true,
"panZoom": false,
"infinitePan": false,
"root": {
"type": "frame",
"name": "Current Enclosure Temperature frame",
"elements": [
{
"type": "metric-value",
"name": "Cell 1",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 12,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "\u00b0C",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "\u00b0C",
"fixed": ""
}
},
"links": []
},
{
"type": "metric-value",
"name": "Cell 2",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 168,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "\u00b0F",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "\u00b0F",
"fixed": ""
}
},
"links": []
}
],
"fields": "",
"values": false
},
"textMode": "value",
"orientation": "horizontal",
"wideLayout": true,
"text": {
"valueSize": 30
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
}
}
},
"links": [
@ -1443,7 +1675,7 @@
},
{
"id": 143,
"type": "stat",
"type": "canvas",
"title": "Current Enclosure Climate",
"datasource": {
"type": "prometheus",
@ -1471,9 +1703,6 @@
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
@ -1488,9 +1717,8 @@
}
]
},
"unit": "none",
"custom": {
"displayMode": "auto"
"color": {
"mode": "thresholds"
}
},
"overrides": [
@ -1521,21 +1749,103 @@
]
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"reduceOptions": {
"calcs": [
"lastNotNull"
"inlineEditing": false,
"showAdvancedTypes": true,
"panZoom": false,
"infinitePan": false,
"root": {
"type": "frame",
"name": "Current Enclosure Climate frame",
"elements": [
{
"type": "metric-value",
"name": "Cell 1",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 12,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "%RH",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "%RH",
"fixed": ""
}
},
"links": []
},
{
"type": "metric-value",
"name": "Cell 2",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 168,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "kPa",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "kPa",
"fixed": ""
}
},
"links": []
}
],
"fields": "",
"values": false
},
"textMode": "value",
"orientation": "horizontal",
"wideLayout": true,
"text": {
"valueSize": 30
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
}
}
},
"links": [

View File

@ -1081,7 +1081,7 @@ data:
},
{
"id": 40,
"type": "stat",
"type": "canvas",
"title": "Pyrphoros UPS Current",
"datasource": {
"type": "prometheus",
@ -1109,9 +1109,6 @@ data:
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
@ -1126,11 +1123,9 @@ data:
}
]
},
"unit": "none",
"custom": {
"displayMode": "auto"
},
"decimals": 1
"color": {
"mode": "thresholds"
}
},
"overrides": [
{
@ -1160,21 +1155,103 @@ data:
]
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"reduceOptions": {
"calcs": [
"lastNotNull"
"inlineEditing": false,
"showAdvancedTypes": true,
"panZoom": false,
"infinitePan": false,
"root": {
"type": "frame",
"name": "Pyrphoros UPS Current frame",
"elements": [
{
"type": "metric-value",
"name": "Cell 1",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 12,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "Draw",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "Draw",
"fixed": ""
}
},
"links": []
},
{
"type": "metric-value",
"name": "Cell 2",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 168,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "Runtime",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "Runtime",
"fixed": ""
}
},
"links": []
}
],
"fields": "",
"values": false
},
"textMode": "value",
"orientation": "horizontal",
"wideLayout": true,
"text": {
"valueSize": 30
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
}
}
},
"links": [
@ -1187,7 +1264,7 @@ data:
},
{
"id": 144,
"type": "stat",
"type": "canvas",
"title": "Statera UPS Current",
"datasource": {
"type": "prometheus",
@ -1215,9 +1292,6 @@ data:
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
@ -1232,11 +1306,9 @@ data:
}
]
},
"unit": "none",
"custom": {
"displayMode": "auto"
},
"decimals": 1
"color": {
"mode": "thresholds"
}
},
"overrides": [
{
@ -1266,21 +1338,103 @@ data:
]
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"reduceOptions": {
"calcs": [
"lastNotNull"
"inlineEditing": false,
"showAdvancedTypes": true,
"panZoom": false,
"infinitePan": false,
"root": {
"type": "frame",
"name": "Statera UPS Current frame",
"elements": [
{
"type": "metric-value",
"name": "Cell 1",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 12,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "Draw",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "Draw",
"fixed": ""
}
},
"links": []
},
{
"type": "metric-value",
"name": "Cell 2",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 168,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "Runtime",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "Runtime",
"fixed": ""
}
},
"links": []
}
],
"fields": "",
"values": false
},
"textMode": "value",
"orientation": "horizontal",
"wideLayout": true,
"text": {
"valueSize": 30
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
}
}
},
"links": [
@ -1347,7 +1501,7 @@ data:
},
{
"id": 42,
"type": "stat",
"type": "canvas",
"title": "Current Enclosure Temperature",
"datasource": {
"type": "prometheus",
@ -1375,9 +1529,6 @@ data:
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
@ -1392,9 +1543,8 @@ data:
}
]
},
"unit": "none",
"custom": {
"displayMode": "auto"
"color": {
"mode": "thresholds"
}
},
"overrides": [
@ -1425,21 +1575,103 @@ data:
]
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"reduceOptions": {
"calcs": [
"lastNotNull"
"inlineEditing": false,
"showAdvancedTypes": true,
"panZoom": false,
"infinitePan": false,
"root": {
"type": "frame",
"name": "Current Enclosure Temperature frame",
"elements": [
{
"type": "metric-value",
"name": "Cell 1",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 12,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "\u00b0C",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "\u00b0C",
"fixed": ""
}
},
"links": []
},
{
"type": "metric-value",
"name": "Cell 2",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 168,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "\u00b0F",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "\u00b0F",
"fixed": ""
}
},
"links": []
}
],
"fields": "",
"values": false
},
"textMode": "value",
"orientation": "horizontal",
"wideLayout": true,
"text": {
"valueSize": 30
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
}
}
},
"links": [
@ -1452,7 +1684,7 @@ data:
},
{
"id": 143,
"type": "stat",
"type": "canvas",
"title": "Current Enclosure Climate",
"datasource": {
"type": "prometheus",
@ -1480,9 +1712,6 @@ data:
],
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
@ -1497,9 +1726,8 @@ data:
}
]
},
"unit": "none",
"custom": {
"displayMode": "auto"
"color": {
"mode": "thresholds"
}
},
"overrides": [
@ -1530,21 +1758,103 @@ data:
]
},
"options": {
"colorMode": "value",
"graphMode": "none",
"justifyMode": "center",
"reduceOptions": {
"calcs": [
"lastNotNull"
"inlineEditing": false,
"showAdvancedTypes": true,
"panZoom": false,
"infinitePan": false,
"root": {
"type": "frame",
"name": "Current Enclosure Climate frame",
"elements": [
{
"type": "metric-value",
"name": "Cell 1",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 12,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "%RH",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "%RH",
"fixed": ""
}
},
"links": []
},
{
"type": "metric-value",
"name": "Cell 2",
"constraint": {
"horizontal": "left",
"vertical": "top"
},
"placement": {
"left": 168,
"top": 38,
"width": 146,
"height": 42
},
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
},
"config": {
"align": "center",
"valign": "middle",
"size": 30,
"color": {
"field": "kPa",
"fixed": "text"
},
"text": {
"mode": "field",
"field": "kPa",
"fixed": ""
}
},
"links": []
}
],
"fields": "",
"values": false
},
"textMode": "value",
"orientation": "horizontal",
"wideLayout": true,
"text": {
"valueSize": 30
"background": {
"color": {
"fixed": "transparent"
}
},
"border": {
"color": {
"fixed": "transparent"
}
}
}
},
"links": [