{
  "__inputs": [
    {
      "name": "DS_PROMETHEUS",
      "label": "Prometheus",
      "description": "",
      "type": "datasource",
      "pluginId": "prometheus",
      "pluginName": "Prometheus"
    }
  ],
  "__requires": [
    {
      "type": "grafana",
      "id": "grafana",
      "name": "Grafana",
      "version": "10.0.0"
    },
    {
      "type": "datasource",
      "id": "prometheus",
      "name": "Prometheus",
      "version": "1.0.0"
    },
    {
      "type": "panel",
      "id": "gauge",
      "name": "Gauge",
      "version": ""
    },
    {
      "type": "panel",
      "id": "timeseries",
      "name": "Time series",
      "version": ""
    },
    {
      "type": "panel",
      "id": "barchart",
      "name": "Bar chart",
      "version": ""
    },
    {
      "type": "panel",
      "id": "histogram",
      "name": "Histogram",
      "version": ""
    },
    {
      "type": "panel",
      "id": "table",
      "name": "Table",
      "version": ""
    },
    {
      "type": "panel",
      "id": "stat",
      "name": "Stat",
      "version": ""
    }
  ],
  "id": null,
  "uid": "wzp-relay-v1",
  "title": "WarzonePhone Relay Dashboard",
  "description": "Monitoring dashboard for WarzonePhone relay, call quality, inter-relay mesh, and web bridge.",
  "tags": ["wzp", "voip", "relay"],
  "style": "dark",
  "timezone": "browser",
  "editable": true,
  "graphTooltip": 1,
  "fiscalYearStartMonth": 0,
  "liveNow": false,
  "refresh": "10s",
  "schemaVersion": 39,
  "version": 1,
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "templating": {
    "list": []
  },
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": { "type": "grafana", "uid": "-- Grafana --" },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "panels": [
    {
      "type": "row",
      "title": "Relay Health",
      "collapsed": false,
      "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
      "id": 1,
      "panels": []
    },
    {
      "type": "gauge",
      "title": "Active Sessions",
      "gridPos": { "h": 8, "w": 4, "x": 0, "y": 1 },
      "id": 2,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_relay_active_sessions",
          "legendFormat": "sessions",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "thresholds" },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 50 },
              { "color": "red", "value": 100 }
            ]
          },
          "unit": "none",
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      }
    },
    {
      "type": "gauge",
      "title": "Active Rooms",
      "gridPos": { "h": 8, "w": 4, "x": 4, "y": 1 },
      "id": 3,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_relay_active_rooms",
          "legendFormat": "rooms",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "thresholds" },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 25 },
              { "color": "red", "value": 50 }
            ]
          },
          "unit": "none",
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      }
    },
    {
      "type": "timeseries",
      "title": "Packets/sec",
      "gridPos": { "h": 8, "w": 4, "x": 8, "y": 1 },
      "id": 4,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "rate(wzp_relay_packets_forwarded_total[1m])",
          "legendFormat": "packets/s",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 20,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto",
            "gradientMode": "scheme"
          },
          "unit": "pps",
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "single", "sort": "none" },
        "legend": { "displayMode": "list", "placement": "bottom" }
      }
    },
    {
      "type": "timeseries",
      "title": "Bytes/sec",
      "gridPos": { "h": 8, "w": 4, "x": 12, "y": 1 },
      "id": 5,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "rate(wzp_relay_bytes_forwarded_total[1m])",
          "legendFormat": "bytes/s",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 20,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto",
            "gradientMode": "scheme"
          },
          "unit": "Bps",
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "single", "sort": "none" },
        "legend": { "displayMode": "list", "placement": "bottom" }
      }
    },
    {
      "type": "barchart",
      "title": "Auth Success vs Failure",
      "gridPos": { "h": 8, "w": 4, "x": 16, "y": 1 },
      "id": 6,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "rate(wzp_relay_auth_attempts_total[5m])",
          "legendFormat": "{{result}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "stacking": "normal",
            "fillOpacity": 80,
            "lineWidth": 1,
            "gradientMode": "none",
            "axisCenteredZero": false
          },
          "unit": "ops"
        },
        "overrides": [
          {
            "matcher": { "id": "byName", "options": "ok" },
            "properties": [
              { "id": "color", "value": { "fixedColor": "green", "mode": "fixed" } }
            ]
          },
          {
            "matcher": { "id": "byName", "options": "fail" },
            "properties": [
              { "id": "color", "value": { "fixedColor": "red", "mode": "fixed" } }
            ]
          }
        ]
      },
      "options": {
        "tooltip": { "mode": "single", "sort": "none" },
        "legend": { "displayMode": "list", "placement": "bottom" },
        "orientation": "auto",
        "barWidth": 0.9,
        "groupWidth": 0.7,
        "xTickLabelRotation": 0,
        "showValue": "auto",
        "stacking": "normal"
      }
    },
    {
      "type": "histogram",
      "title": "Handshake Duration",
      "gridPos": { "h": 8, "w": 4, "x": 20, "y": 1 },
      "id": 7,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_relay_handshake_duration_seconds_bucket",
          "legendFormat": "{{le}}",
          "refId": "A",
          "format": "heatmap"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "fillOpacity": 80,
            "lineWidth": 1,
            "gradientMode": "scheme"
          },
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "single", "sort": "none" },
        "legend": { "displayMode": "list", "placement": "bottom" },
        "bucketOffset": 0,
        "combine": false,
        "fillOpacity": 80,
        "gradientMode": "scheme"
      }
    },
    {
      "type": "row",
      "title": "Call Quality (per-session)",
      "collapsed": false,
      "gridPos": { "h": 1, "w": 24, "x": 0, "y": 9 },
      "id": 10,
      "panels": []
    },
    {
      "type": "timeseries",
      "title": "Buffer Depth",
      "gridPos": { "h": 8, "w": 6, "x": 0, "y": 10 },
      "id": 11,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_relay_session_jitter_buffer_depth",
          "legendFormat": "{{session_id}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 10,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto"
          },
          "unit": "none",
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "multi", "sort": "desc" },
        "legend": { "displayMode": "table", "placement": "bottom", "calcs": ["lastNotNull", "mean"] }
      }
    },
    {
      "type": "timeseries",
      "title": "Loss %",
      "gridPos": { "h": 8, "w": 6, "x": 6, "y": 10 },
      "id": 12,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_relay_session_loss_pct",
          "legendFormat": "{{session_id}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 10,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto"
          },
          "unit": "percent",
          "min": 0,
          "max": 100,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 2 },
              { "color": "red", "value": 5 }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "multi", "sort": "desc" },
        "legend": { "displayMode": "table", "placement": "bottom", "calcs": ["lastNotNull", "mean", "max"] }
      }
    },
    {
      "type": "timeseries",
      "title": "RTT",
      "gridPos": { "h": 8, "w": 6, "x": 12, "y": 10 },
      "id": 13,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_relay_session_rtt_ms",
          "legendFormat": "{{session_id}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 10,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto"
          },
          "unit": "ms",
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 100 },
              { "color": "red", "value": 300 }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "multi", "sort": "desc" },
        "legend": { "displayMode": "table", "placement": "bottom", "calcs": ["lastNotNull", "mean", "max"] }
      }
    },
    {
      "type": "timeseries",
      "title": "Underruns",
      "gridPos": { "h": 8, "w": 6, "x": 18, "y": 10 },
      "id": 14,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "rate(wzp_relay_session_underruns_total[1m])",
          "legendFormat": "{{session_id}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 10,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto"
          },
          "unit": "ops",
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "multi", "sort": "desc" },
        "legend": { "displayMode": "table", "placement": "bottom", "calcs": ["lastNotNull", "mean"] }
      }
    },
    {
      "type": "row",
      "title": "Inter-Relay Mesh",
      "collapsed": false,
      "gridPos": { "h": 1, "w": 24, "x": 0, "y": 18 },
      "id": 20,
      "panels": []
    },
    {
      "type": "table",
      "title": "RTT Heatmap",
      "gridPos": { "h": 8, "w": 6, "x": 0, "y": 19 },
      "id": 21,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_probe_rtt_ms",
          "legendFormat": "{{target}}",
          "refId": "A",
          "instant": true,
          "format": "table"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "thresholds" },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 50 },
              { "color": "orange", "value": 100 },
              { "color": "red", "value": 200 }
            ]
          },
          "unit": "ms",
          "custom": {
            "displayMode": "color-background",
            "align": "auto",
            "inspect": false
          }
        },
        "overrides": []
      },
      "options": {
        "showHeader": true,
        "sortBy": [{ "displayName": "Value", "desc": true }],
        "cellHeight": "sm",
        "footer": { "show": false }
      },
      "transformations": [
        {
          "id": "organize",
          "options": {
            "excludeByName": { "Time": true, "__name__": true, "instance": true, "job": true },
            "renameByName": { "target": "Target", "Value": "RTT (ms)" }
          }
        }
      ]
    },
    {
      "type": "timeseries",
      "title": "Loss",
      "gridPos": { "h": 8, "w": 6, "x": 6, "y": 19 },
      "id": 22,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_probe_loss_pct",
          "legendFormat": "{{target}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 10,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto"
          },
          "unit": "percent",
          "min": 0,
          "max": 100,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 1 },
              { "color": "red", "value": 5 }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "multi", "sort": "desc" },
        "legend": { "displayMode": "table", "placement": "bottom", "calcs": ["lastNotNull", "mean", "max"] }
      }
    },
    {
      "type": "timeseries",
      "title": "Jitter",
      "gridPos": { "h": 8, "w": 6, "x": 12, "y": 19 },
      "id": 23,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_probe_jitter_ms",
          "legendFormat": "{{target}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 10,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto"
          },
          "unit": "ms",
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 10 },
              { "color": "red", "value": 30 }
            ]
          }
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "multi", "sort": "desc" },
        "legend": { "displayMode": "table", "placement": "bottom", "calcs": ["lastNotNull", "mean", "max"] }
      }
    },
    {
      "type": "stat",
      "title": "Probe Status",
      "gridPos": { "h": 8, "w": 6, "x": 18, "y": 19 },
      "id": 24,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_probe_up",
          "legendFormat": "{{target}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "thresholds" },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "red", "value": null },
              { "color": "green", "value": 1 }
            ]
          },
          "mappings": [
            { "type": "value", "options": { "0": { "text": "DOWN", "color": "red" }, "1": { "text": "UP", "color": "green" } } }
          ],
          "unit": "none",
          "min": 0,
          "max": 1
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "textMode": "auto",
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto"
      }
    },
    {
      "type": "row",
      "title": "Web Bridge",
      "collapsed": false,
      "gridPos": { "h": 1, "w": 24, "x": 0, "y": 27 },
      "id": 30,
      "panels": []
    },
    {
      "type": "gauge",
      "title": "Active Connections",
      "gridPos": { "h": 8, "w": 6, "x": 0, "y": 28 },
      "id": 31,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_web_active_connections",
          "legendFormat": "connections",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "thresholds" },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              { "color": "green", "value": null },
              { "color": "yellow", "value": 50 },
              { "color": "red", "value": 100 }
            ]
          },
          "unit": "none",
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": ["lastNotNull"],
          "fields": "",
          "values": false
        },
        "showThresholdLabels": false,
        "showThresholdMarkers": true
      }
    },
    {
      "type": "timeseries",
      "title": "Frames Bridged",
      "gridPos": { "h": 8, "w": 6, "x": 6, "y": 28 },
      "id": 32,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "rate(wzp_web_frames_bridged_total[1m])",
          "legendFormat": "{{direction}}",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 20,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto",
            "gradientMode": "scheme"
          },
          "unit": "ops",
          "min": 0
        },
        "overrides": [
          {
            "matcher": { "id": "byName", "options": "up" },
            "properties": [
              { "id": "color", "value": { "fixedColor": "blue", "mode": "fixed" } }
            ]
          },
          {
            "matcher": { "id": "byName", "options": "down" },
            "properties": [
              { "id": "color", "value": { "fixedColor": "purple", "mode": "fixed" } }
            ]
          }
        ]
      },
      "options": {
        "tooltip": { "mode": "multi", "sort": "desc" },
        "legend": { "displayMode": "list", "placement": "bottom" }
      }
    },
    {
      "type": "timeseries",
      "title": "Auth Failures",
      "gridPos": { "h": 8, "w": 6, "x": 12, "y": 28 },
      "id": 33,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "rate(wzp_web_auth_failures_total[5m])",
          "legendFormat": "auth failures/s",
          "refId": "A"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "fixed", "fixedColor": "red" },
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "fillOpacity": 20,
            "lineWidth": 2,
            "pointSize": 5,
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": { "mode": "none", "group": "A" },
            "axisPlacement": "auto"
          },
          "unit": "ops",
          "min": 0
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "single", "sort": "none" },
        "legend": { "displayMode": "list", "placement": "bottom" }
      }
    },
    {
      "type": "histogram",
      "title": "Handshake Latency",
      "gridPos": { "h": 8, "w": 6, "x": 18, "y": 28 },
      "id": 34,
      "datasource": { "type": "prometheus", "uid": "${DS_PROMETHEUS}" },
      "targets": [
        {
          "expr": "wzp_web_handshake_latency_seconds_bucket",
          "legendFormat": "{{le}}",
          "refId": "A",
          "format": "heatmap"
        }
      ],
      "fieldConfig": {
        "defaults": {
          "color": { "mode": "palette-classic" },
          "custom": {
            "fillOpacity": 80,
            "lineWidth": 1,
            "gradientMode": "scheme"
          },
          "unit": "s"
        },
        "overrides": []
      },
      "options": {
        "tooltip": { "mode": "single", "sort": "none" },
        "legend": { "displayMode": "list", "placement": "bottom" },
        "bucketOffset": 0,
        "combine": false,
        "fillOpacity": 80,
        "gradientMode": "scheme"
      }
    }
  ]
}
