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