monitoring: rebuild split ups and climate cards from scratch
This commit is contained in:
parent
aa935984a8
commit
56cca6df83
@ -1157,49 +1157,46 @@ def canvas_metric_grid_panel(
|
|||||||
return panel
|
return panel
|
||||||
|
|
||||||
|
|
||||||
def canvas_two_metric_row_panel(
|
def overview_two_value_panel(
|
||||||
panel_id,
|
panel_id,
|
||||||
title,
|
title,
|
||||||
grid,
|
grid,
|
||||||
*,
|
*,
|
||||||
targets,
|
left_target,
|
||||||
|
right_target,
|
||||||
field_overrides=None,
|
field_overrides=None,
|
||||||
links=None,
|
links=None,
|
||||||
description=None,
|
description=None,
|
||||||
metric_size=30,
|
|
||||||
metric_top=10,
|
|
||||||
metric_height=42,
|
|
||||||
color_fields=None,
|
|
||||||
thresholds=None,
|
thresholds=None,
|
||||||
):
|
):
|
||||||
"""Return a canvas panel with two values rendered side-by-side and no labels."""
|
"""Return a dedicated two-value overview canvas panel."""
|
||||||
|
|
||||||
if color_fields is None:
|
top = 10
|
||||||
color_fields = [targets[0]["legendFormat"], targets[1]["legendFormat"]]
|
size = 30
|
||||||
|
width = 146
|
||||||
|
height = 42
|
||||||
|
left_x = 12
|
||||||
|
right_x = 168
|
||||||
|
|
||||||
def metric_element(name, field, left, top, color_field):
|
targets = [
|
||||||
|
{"refId": "A", "expr": left_target["expr"], "legendFormat": left_target["legend"], "instant": True},
|
||||||
|
{"refId": "B", "expr": right_target["expr"], "legendFormat": right_target["legend"], "instant": True},
|
||||||
|
]
|
||||||
|
|
||||||
|
def metric_element(name, field, color_field, left):
|
||||||
return {
|
return {
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": name,
|
"name": name,
|
||||||
"constraint": {"horizontal": "left", "vertical": "top"},
|
"constraint": {"horizontal": "left", "vertical": "top"},
|
||||||
"placement": {
|
"placement": {"left": left, "top": top, "width": width, "height": height},
|
||||||
"left": left,
|
|
||||||
"top": top,
|
|
||||||
"width": 146,
|
|
||||||
"height": metric_height,
|
|
||||||
},
|
|
||||||
"background": {"color": {"fixed": "transparent"}},
|
"background": {"color": {"fixed": "transparent"}},
|
||||||
"border": {"color": {"fixed": "transparent"}},
|
"border": {"color": {"fixed": "transparent"}},
|
||||||
"config": {
|
"config": {
|
||||||
"align": "center",
|
"align": "center",
|
||||||
"valign": "middle",
|
"valign": "middle",
|
||||||
"size": metric_size,
|
"size": size,
|
||||||
"color": {"field": color_field, "fixed": "text"},
|
"color": {"field": color_field, "fixed": "text"},
|
||||||
"text": {
|
"text": {"mode": "field", "field": field, "fixed": ""},
|
||||||
"mode": "field",
|
|
||||||
"field": field,
|
|
||||||
"fixed": "",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"links": [],
|
"links": [],
|
||||||
}
|
}
|
||||||
@ -1235,8 +1232,8 @@ def canvas_two_metric_row_panel(
|
|||||||
"type": "frame",
|
"type": "frame",
|
||||||
"name": f"{title} frame",
|
"name": f"{title} frame",
|
||||||
"elements": [
|
"elements": [
|
||||||
metric_element("Cell 1", targets[0]["legendFormat"], 12, metric_top, color_fields[0]),
|
metric_element("Left value", left_target["legend"], left_target["legend"], left_x),
|
||||||
metric_element("Cell 2", targets[1]["legendFormat"], 168, metric_top, color_fields[1]),
|
metric_element("Right value", right_target["legend"], right_target["legend"], right_x),
|
||||||
],
|
],
|
||||||
"background": {"color": {"fixed": "transparent"}},
|
"background": {"color": {"fixed": "transparent"}},
|
||||||
"border": {"color": {"fixed": "transparent"}},
|
"border": {"color": {"fixed": "transparent"}},
|
||||||
@ -1836,17 +1833,12 @@ def build_overview():
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
panels.append(
|
panels.append(
|
||||||
canvas_two_metric_row_panel(
|
overview_two_value_panel(
|
||||||
40,
|
40,
|
||||||
f"{ANANKE_UPS_DB_NAME} UPS Current",
|
f"{ANANKE_UPS_DB_NAME} UPS Current",
|
||||||
{"h": 3, "w": 6, "x": 0, "y": 7},
|
{"h": 3, "w": 6, "x": 0, "y": 7},
|
||||||
metric_size=30,
|
left_target={"expr": ANANKE_UPS_DRAW_WATTS_DB, "legend": "Draw"},
|
||||||
metric_top=10,
|
right_target={"expr": ANANKE_UPS_RUNTIME_DB, "legend": "Runtime"},
|
||||||
metric_height=42,
|
|
||||||
targets=[
|
|
||||||
{"refId": "A", "expr": ANANKE_UPS_DRAW_WATTS_DB, "legendFormat": "Draw", "instant": True},
|
|
||||||
{"refId": "B", "expr": ANANKE_UPS_RUNTIME_DB, "legendFormat": "Runtime", "instant": True},
|
|
||||||
],
|
|
||||||
field_overrides=[
|
field_overrides=[
|
||||||
{"matcher": {"id": "byName", "options": "Draw"}, "properties": [{"id": "unit", "value": "watt"}]},
|
{"matcher": {"id": "byName", "options": "Draw"}, "properties": [{"id": "unit", "value": "watt"}]},
|
||||||
{"matcher": {"id": "byName", "options": "Runtime"}, "properties": [{"id": "unit", "value": "s"}]},
|
{"matcher": {"id": "byName", "options": "Runtime"}, "properties": [{"id": "unit", "value": "s"}]},
|
||||||
@ -1855,15 +1847,12 @@ def build_overview():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
panels.append(
|
panels.append(
|
||||||
canvas_two_metric_row_panel(
|
overview_two_value_panel(
|
||||||
144,
|
144,
|
||||||
f"{ANANKE_UPS_TETHYS_NAME} UPS Current",
|
f"{ANANKE_UPS_TETHYS_NAME} UPS Current",
|
||||||
{"h": 3, "w": 6, "x": 0, "y": 10},
|
{"h": 3, "w": 6, "x": 0, "y": 10},
|
||||||
metric_size=30,
|
left_target={"expr": ANANKE_UPS_DRAW_WATTS_TETHYS, "legend": "Draw"},
|
||||||
targets=[
|
right_target={"expr": ANANKE_UPS_RUNTIME_TETHYS, "legend": "Runtime"},
|
||||||
{"refId": "A", "expr": ANANKE_UPS_DRAW_WATTS_TETHYS, "legendFormat": "Draw", "instant": True},
|
|
||||||
{"refId": "B", "expr": ANANKE_UPS_RUNTIME_TETHYS, "legendFormat": "Runtime", "instant": True},
|
|
||||||
],
|
|
||||||
field_overrides=[
|
field_overrides=[
|
||||||
{"matcher": {"id": "byName", "options": "Draw"}, "properties": [{"id": "unit", "value": "watt"}]},
|
{"matcher": {"id": "byName", "options": "Draw"}, "properties": [{"id": "unit", "value": "watt"}]},
|
||||||
{"matcher": {"id": "byName", "options": "Runtime"}, "properties": [{"id": "unit", "value": "s"}]},
|
{"matcher": {"id": "byName", "options": "Runtime"}, "properties": [{"id": "unit", "value": "s"}]},
|
||||||
@ -1889,15 +1878,12 @@ def build_overview():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
panels.append(
|
panels.append(
|
||||||
canvas_two_metric_row_panel(
|
overview_two_value_panel(
|
||||||
42,
|
42,
|
||||||
"Current Enclosure Temperature",
|
"Current Enclosure Temperature",
|
||||||
{"h": 3, "w": 6, "x": 0, "y": 13},
|
{"h": 3, "w": 6, "x": 0, "y": 13},
|
||||||
metric_size=30,
|
left_target={"expr": CLIMATE_TEMP_MAX, "legend": "°C"},
|
||||||
targets=[
|
right_target={"expr": CLIMATE_TEMP_FAHRENHEIT_MAX, "legend": "°F"},
|
||||||
{"refId": "A", "expr": CLIMATE_TEMP_MAX, "legendFormat": "°C", "instant": True},
|
|
||||||
{"refId": "B", "expr": CLIMATE_TEMP_FAHRENHEIT_MAX, "legendFormat": "°F", "instant": True},
|
|
||||||
],
|
|
||||||
field_overrides=[
|
field_overrides=[
|
||||||
{"matcher": {"id": "byName", "options": "°C"}, "properties": [{"id": "unit", "value": "celsius"}]},
|
{"matcher": {"id": "byName", "options": "°C"}, "properties": [{"id": "unit", "value": "celsius"}]},
|
||||||
{"matcher": {"id": "byName", "options": "°F"}, "properties": [{"id": "unit", "value": "fahrenheit"}]},
|
{"matcher": {"id": "byName", "options": "°F"}, "properties": [{"id": "unit", "value": "fahrenheit"}]},
|
||||||
@ -1906,15 +1892,12 @@ def build_overview():
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
panels.append(
|
panels.append(
|
||||||
canvas_two_metric_row_panel(
|
overview_two_value_panel(
|
||||||
143,
|
143,
|
||||||
"Current Enclosure Climate",
|
"Current Enclosure Climate",
|
||||||
{"h": 3, "w": 6, "x": 0, "y": 16},
|
{"h": 3, "w": 6, "x": 0, "y": 16},
|
||||||
metric_size=30,
|
left_target={"expr": CLIMATE_HUMIDITY_MAX, "legend": "%RH"},
|
||||||
targets=[
|
right_target={"expr": CLIMATE_PRESSURE_CURRENT, "legend": "kPa"},
|
||||||
{"refId": "A", "expr": CLIMATE_HUMIDITY_MAX, "legendFormat": "%RH", "instant": True},
|
|
||||||
{"refId": "B", "expr": CLIMATE_PRESSURE_CURRENT, "legendFormat": "kPa", "instant": True},
|
|
||||||
],
|
|
||||||
field_overrides=[
|
field_overrides=[
|
||||||
{"matcher": {"id": "byName", "options": "%RH"}, "properties": [{"id": "unit", "value": "suffix:%RH"}]},
|
{"matcher": {"id": "byName", "options": "%RH"}, "properties": [{"id": "unit", "value": "suffix:%RH"}]},
|
||||||
{"matcher": {"id": "byName", "options": "kPa"}, "properties": [{"id": "unit", "value": "suffix:kPa"}]},
|
{"matcher": {"id": "byName", "options": "kPa"}, "properties": [{"id": "unit", "value": "suffix:kPa"}]},
|
||||||
|
|||||||
@ -1156,7 +1156,7 @@
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 1",
|
"name": "Left value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1195,7 +1195,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 2",
|
"name": "Right value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1339,7 +1339,7 @@
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 1",
|
"name": "Left value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1378,7 +1378,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 2",
|
"name": "Right value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1576,7 +1576,7 @@
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 1",
|
"name": "Left value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1615,7 +1615,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 2",
|
"name": "Right value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1759,7 +1759,7 @@
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 1",
|
"name": "Left value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1798,7 +1798,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 2",
|
"name": "Right value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
|
|||||||
@ -1165,7 +1165,7 @@ data:
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 1",
|
"name": "Left value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1204,7 +1204,7 @@ data:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 2",
|
"name": "Right value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1348,7 +1348,7 @@ data:
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 1",
|
"name": "Left value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1387,7 +1387,7 @@ data:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 2",
|
"name": "Right value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1585,7 +1585,7 @@ data:
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 1",
|
"name": "Left value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1624,7 +1624,7 @@ data:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 2",
|
"name": "Right value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1768,7 +1768,7 @@ data:
|
|||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 1",
|
"name": "Left value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
@ -1807,7 +1807,7 @@ data:
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "metric-value",
|
"type": "metric-value",
|
||||||
"name": "Cell 2",
|
"name": "Right value",
|
||||||
"constraint": {
|
"constraint": {
|
||||||
"horizontal": "left",
|
"horizontal": "left",
|
||||||
"vertical": "top"
|
"vertical": "top"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user