# services/monitoring/grafana-dashboard-power.yaml
apiVersion: v1
kind: ConfigMap
metadata:
  name: grafana-dashboard-power
  labels:
    grafana_dashboard: "1"
data:
  atlas-power.json: |
    {
      "uid": "atlas-power",
      "title": "Atlas Power",
      "folderUid": "atlas-internal",
      "editable": true,
      "panels": [
        {
          "id": 1,
          "type": "stat",
          "title": "UPS Current Load",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 0,
            "y": 0
          },
          "targets": [
            {
              "refId": "A",
              "expr": "max((ananke_ups_load_percent{job=\"ananke-power\",source=\"Pyrphoros\"} * ananke_ups_power_nominal_watts{job=\"ananke-power\",source=\"Pyrphoros\"}) / 100) or on() vector(0)",
              "legendFormat": "Pyrphoros Draw (W)",
              "instant": true
            },
            {
              "refId": "B",
              "expr": "max(ananke_ups_runtime_seconds{job=\"ananke-power\",source=\"Pyrphoros\"}) or on() vector(0)",
              "legendFormat": "Pyrphoros Discharge",
              "instant": true
            },
            {
              "refId": "C",
              "expr": "max(ananke_ups_on_battery{job=\"ananke-power\",source=\"Pyrphoros\"}) or on() vector(0)",
              "legendFormat": "Pyrphoros Status",
              "instant": true
            },
            {
              "refId": "D",
              "expr": "max((ananke_ups_load_percent{job=\"ananke-power\",source=\"Statera\"} * ananke_ups_power_nominal_watts{job=\"ananke-power\",source=\"Statera\"}) / 100) or on() vector(0)",
              "legendFormat": "Statera Draw (W)",
              "instant": true
            },
            {
              "refId": "E",
              "expr": "max(ananke_ups_runtime_seconds{job=\"ananke-power\",source=\"Statera\"}) or on() vector(0)",
              "legendFormat": "Statera Discharge",
              "instant": true
            },
            {
              "refId": "F",
              "expr": "max(ananke_ups_on_battery{job=\"ananke-power\",source=\"Statera\"}) or on() vector(0)",
              "legendFormat": "Statera Status",
              "instant": true
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "rgba(115, 115, 115, 1)",
                    "value": null
                  },
                  {
                    "color": "dark-green",
                    "value": 1
                  }
                ]
              },
              "unit": "none",
              "custom": {
                "displayMode": "auto"
              },
              "decimals": 1
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "Pyrphoros Draw (W)"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "watt"
                  },
                  {
                    "id": "description",
                    "value": "Attached node: titan-db"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Statera Draw (W)"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "watt"
                  },
                  {
                    "id": "description",
                    "value": "Attached node: titan-24"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Pyrphoros Discharge"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "s"
                  },
                  {
                    "id": "description",
                    "value": "Attached node: titan-db"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Statera Discharge"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "s"
                  },
                  {
                    "id": "description",
                    "value": "Attached node: titan-24"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Pyrphoros Status"
                },
                "properties": [
                  {
                    "id": "mappings",
                    "value": [
                      {
                        "type": "value",
                        "options": {
                          "0": {
                            "text": "\u26a1 Charging"
                          },
                          "1": {
                            "text": "\ud83d\udd0b Discharging"
                          }
                        }
                      }
                    ]
                  },
                  {
                    "id": "description",
                    "value": "Attached node: titan-db"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Statera Status"
                },
                "properties": [
                  {
                    "id": "mappings",
                    "value": [
                      {
                        "type": "value",
                        "options": {
                          "0": {
                            "text": "\u26a1 Charging"
                          },
                          "1": {
                            "text": "\ud83d\udd0b Discharging"
                          }
                        }
                      }
                    ]
                  },
                  {
                    "id": "description",
                    "value": "Attached node: titan-24"
                  }
                ]
              }
            ]
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "name_and_value",
            "orientation": "horizontal",
            "wideLayout": true
          },
          "description": "Per-UPS live snapshot: current draw in watts, estimated battery runtime if discharge started now, and charging/discharging status."
        },
        {
          "id": 2,
          "type": "timeseries",
          "title": "UPS History (Power Draw)",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 12,
            "y": 0
          },
          "targets": [
            {
              "refId": "A",
              "expr": "max((ananke_ups_load_percent{job=\"ananke-power\",source=\"Pyrphoros\"} * ananke_ups_power_nominal_watts{job=\"ananke-power\",source=\"Pyrphoros\"}) / 100)",
              "legendFormat": "Pyrphoros"
            },
            {
              "refId": "B",
              "expr": "max((ananke_ups_load_percent{job=\"ananke-power\",source=\"Statera\"} * ananke_ups_power_nominal_watts{job=\"ananke-power\",source=\"Statera\"}) / 100)",
              "legendFormat": "Statera"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "watt",
              "custom": {
                "drawStyle": "bars",
                "barAlignment": 0,
                "barWidthFactor": 0.72,
                "lineWidth": 0,
                "fillOpacity": 70,
                "gradientMode": "none",
                "showPoints": "never",
                "spanNulls": true
              }
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "Pyrphoros"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "mode": "fixed",
                      "fixedColor": "dark-blue"
                    }
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Statera"
                },
                "properties": [
                  {
                    "id": "color",
                    "value": {
                      "mode": "fixed",
                      "fixedColor": "dark-yellow"
                    }
                  }
                ]
              }
            ]
          },
          "options": {
            "legend": {
              "displayMode": "table",
              "placement": "right"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "description": "Historical UPS power consumption in watts for titan-db and tethys."
        },
        {
          "id": 3,
          "type": "stat",
          "title": "Current Climate",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 0,
            "y": 8
          },
          "targets": [
            {
              "refId": "A",
              "expr": "max(max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0)) or on() vector(0)",
              "legendFormat": "Tent Temp (\u00b0C)",
              "instant": true
            },
            {
              "refId": "B",
              "expr": "max(max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_vpd_kpa != 0)) or on() vector(0)",
              "legendFormat": "Tent VPD (kPa)",
              "instant": true
            },
            {
              "refId": "C",
              "expr": "max(max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_relative_humidity_percent != 0)) or on() vector(0)",
              "legendFormat": "Tent RH (%)",
              "instant": true
            },
            {
              "refId": "D",
              "expr": "max((243.12 * (ln(clamp_min((max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_relative_humidity_percent != 0)), 1) / 100) + (17.62 * (max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0))) / (243.12 + (max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0))))) / (17.62 - (ln(clamp_min((max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_relative_humidity_percent != 0)), 1) / 100) + (17.62 * (max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0))) / (243.12 + (max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0)))))) or on() vector(0)",
              "legendFormat": "Dew Point (\u00b0C)",
              "instant": true
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "rgba(115, 115, 115, 1)",
                    "value": null
                  },
                  {
                    "color": "dark-green",
                    "value": 1
                  }
                ]
              },
              "unit": "none",
              "custom": {
                "displayMode": "auto"
              },
              "decimals": 2
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "Tent Temp (\u00b0C)"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "celsius"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Tent VPD (kPa)"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "suffix:kPa"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Tent RH (%)"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "percent"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "Dew Point (\u00b0C)"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "celsius"
                  }
                ]
              }
            ]
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "name_and_value",
            "orientation": "horizontal",
            "wideLayout": true
          },
          "description": "Current tent temperature, humidity, VPD, and dew point. These render once Typhon climate telemetry is online."
        },
        {
          "id": 4,
          "type": "timeseries",
          "title": "Climate History",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 12,
            "y": 8
          },
          "targets": [
            {
              "refId": "A",
              "expr": "max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0)",
              "legendFormat": "Temperature (\u00b0C)"
            },
            {
              "refId": "B",
              "expr": "max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_relative_humidity_percent != 0)",
              "legendFormat": "Humidity (%)"
            },
            {
              "refId": "C",
              "expr": "max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_vpd_kpa != 0)",
              "legendFormat": "VPD (kPa)"
            },
            {
              "refId": "D",
              "expr": "(243.12 * (ln(clamp_min((max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_relative_humidity_percent != 0)), 1) / 100) + (17.62 * (max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0))) / (243.12 + (max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0))))) / (17.62 - (ln(clamp_min((max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_relative_humidity_percent != 0)), 1) / 100) + (17.62 * (max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0))) / (243.12 + (max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_temperature_celsius != 0)))))",
              "legendFormat": "Dew Point (\u00b0C)"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "celsius"
            },
            "overrides": [
              {
                "matcher": {
                  "id": "byName",
                  "options": "Humidity (%)"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "percent"
                  }
                ]
              },
              {
                "matcher": {
                  "id": "byName",
                  "options": "VPD (kPa)"
                },
                "properties": [
                  {
                    "id": "unit",
                    "value": "none"
                  },
                  {
                    "id": "custom.axisPlacement",
                    "value": "right"
                  },
                  {
                    "id": "custom.axisLabel",
                    "value": "kPa"
                  },
                  {
                    "id": "decimals",
                    "value": 2
                  }
                ]
              }
            ]
          },
          "options": {
            "legend": {
              "displayMode": "table",
              "placement": "right"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "description": "Two-axis chart: tent temperature/humidity/dew point (left axis) and tent VPD in kPa (right axis)."
        },
        {
          "id": 5,
          "type": "stat",
          "title": "Fan Activity",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 0,
            "y": 16
          },
          "targets": [
            {
              "refId": "A",
              "expr": "round(max(typhon_fan_speed_level{fan_group=\"outlet\"}) or on() vector(0))",
              "legendFormat": "Inside Outlet",
              "instant": true
            },
            {
              "refId": "B",
              "expr": "round(max(typhon_fan_speed_level{fan_group=\"inside_inlet\"}) or on() vector(0))",
              "legendFormat": "Inside Inlet",
              "instant": true
            },
            {
              "refId": "C",
              "expr": "round(max(typhon_fan_speed_level{fan_group=\"outside_inlet\"}) or on() vector(0))",
              "legendFormat": "Outside Inlet",
              "instant": true
            },
            {
              "refId": "D",
              "expr": "round(max(typhon_fan_speed_level{fan_group=\"interior\"}) or on() vector(0))",
              "legendFormat": "Interior Fans",
              "instant": true
            }
          ],
          "fieldConfig": {
            "defaults": {
              "color": {
                "mode": "thresholds"
              },
              "mappings": [],
              "thresholds": {
                "mode": "absolute",
                "steps": [
                  {
                    "color": "dark-green",
                    "value": null
                  },
                  {
                    "color": "dark-yellow",
                    "value": 7
                  },
                  {
                    "color": "dark-red",
                    "value": 9
                  }
                ]
              },
              "unit": "none",
              "custom": {
                "displayMode": "auto"
              },
              "decimals": 0
            },
            "overrides": []
          },
          "options": {
            "colorMode": "value",
            "graphMode": "area",
            "justifyMode": "center",
            "reduceOptions": {
              "calcs": [
                "lastNotNull"
              ],
              "fields": "",
              "values": false
            },
            "textMode": "name_and_value",
            "orientation": "horizontal",
            "wideLayout": true
          },
          "description": "Current fan activity levels (0-10): inside outlet, inside inlet, outside inlet, and interior fans."
        },
        {
          "id": 6,
          "type": "timeseries",
          "title": "Fan Intensity History",
          "datasource": {
            "type": "prometheus",
            "uid": "atlas-vm"
          },
          "gridPos": {
            "h": 8,
            "w": 12,
            "x": 12,
            "y": 16
          },
          "targets": [
            {
              "refId": "A",
              "expr": "max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_fan_speed_level{fan_group=\"outlet\"})",
              "legendFormat": "Inside Outlet"
            },
            {
              "refId": "B",
              "expr": "max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_fan_speed_level{fan_group=\"inside_inlet\"})",
              "legendFormat": "Inside Inlet"
            },
            {
              "refId": "C",
              "expr": "max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_fan_speed_level{fan_group=\"outside_inlet\"})",
              "legendFormat": "Outside Inlet"
            },
            {
              "refId": "D",
              "expr": "max without (job,instance,pod,service,endpoint,namespace,node,controller_name,controller_id,port_name,fan_group) (typhon_fan_speed_level{fan_group=\"interior\"})",
              "legendFormat": "Interior Fans"
            }
          ],
          "fieldConfig": {
            "defaults": {
              "unit": "none",
              "max": 10
            },
            "overrides": []
          },
          "options": {
            "legend": {
              "displayMode": "table",
              "placement": "right"
            },
            "tooltip": {
              "mode": "multi"
            }
          },
          "description": "Historical fan activity for all four fan groups (0-10 scale)."
        }
      ],
      "time": {
        "from": "now-24h",
        "to": "now"
      },
      "annotations": {
        "list": []
      },
      "schemaVersion": 39,
      "style": "dark",
      "tags": [
        "atlas",
        "power",
        "climate"
      ]
    }
