{
  "dashboard": {
    "id": null,
    "uid": "agent-os-amb",
    "title": "Agent OS - AMB Health",
    "tags": [
      "agent-os",
      "amb",
      "messaging"
    ],
    "timezone": "browser",
    "schemaVersion": 38,
    "version": 1,
    "refresh": "5s",
    "panels": [
      {
        "id": 1,
        "type": "stat",
        "title": "Messages/sec",
        "gridPos": {
          "h": 4,
          "w": 6,
          "x": 0,
          "y": 0
        },
        "targets": [
          {
            "expr": "sum(rate(amb_messages_published_total[1m]))",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "msg/s",
            "thresholds": {
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "yellow",
                  "value": 10000
                },
                {
                  "color": "red",
                  "value": 50000
                }
              ]
            }
          }
        }
      },
      {
        "id": 2,
        "type": "stat",
        "title": "Queue Depth",
        "gridPos": {
          "h": 4,
          "w": 6,
          "x": 6,
          "y": 0
        },
        "targets": [
          {
            "expr": "sum(amb_queue_depth)",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "thresholds": {
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "yellow",
                  "value": 500
                },
                {
                  "color": "red",
                  "value": 1000
                }
              ]
            }
          }
        }
      },
      {
        "id": 3,
        "type": "stat",
        "title": "Backpressure Events (1h)",
        "gridPos": {
          "h": 4,
          "w": 6,
          "x": 12,
          "y": 0
        },
        "targets": [
          {
            "expr": "increase(amb_backpressure_activated_total[1h])",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "thresholds": {
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "yellow",
                  "value": 1
                },
                {
                  "color": "red",
                  "value": 10
                }
              ]
            }
          }
        }
      },
      {
        "id": 4,
        "type": "stat",
        "title": "Delivery Failures (1h)",
        "gridPos": {
          "h": 4,
          "w": 6,
          "x": 18,
          "y": 0
        },
        "targets": [
          {
            "expr": "increase(amb_delivery_failures_total[1h])",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "thresholds": {
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "yellow",
                  "value": 1
                },
                {
                  "color": "red",
                  "value": 10
                }
              ]
            }
          }
        }
      },
      {
        "id": 5,
        "type": "timeseries",
        "title": "Message Throughput",
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 0,
          "y": 4
        },
        "targets": [
          {
            "expr": "rate(amb_messages_published_total[1m])",
            "legendFormat": "Published - {{topic}}",
            "refId": "A"
          },
          {
            "expr": "rate(amb_messages_delivered_total[1m])",
            "legendFormat": "Delivered - {{topic}}",
            "refId": "B"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "msg/s"
          }
        }
      },
      {
        "id": 6,
        "type": "timeseries",
        "title": "Queue Depth by Topic",
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 12,
          "y": 4
        },
        "targets": [
          {
            "expr": "amb_queue_depth",
            "legendFormat": "{{topic}}",
            "refId": "A"
          }
        ]
      },
      {
        "id": 7,
        "type": "timeseries",
        "title": "Publish Latency",
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 0,
          "y": 12
        },
        "targets": [
          {
            "expr": "histogram_quantile(0.99, rate(amb_publish_duration_seconds_bucket[5m]))",
            "legendFormat": "p99",
            "refId": "A"
          },
          {
            "expr": "histogram_quantile(0.95, rate(amb_publish_duration_seconds_bucket[5m]))",
            "legendFormat": "p95",
            "refId": "B"
          },
          {
            "expr": "histogram_quantile(0.50, rate(amb_publish_duration_seconds_bucket[5m]))",
            "legendFormat": "p50",
            "refId": "C"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "s",
            "thresholds": {
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "yellow",
                  "value": 0.01
                },
                {
                  "color": "red",
                  "value": 0.1
                }
              ]
            }
          }
        }
      },
      {
        "id": 8,
        "type": "timeseries",
        "title": "Delivery Latency",
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 12,
          "y": 12
        },
        "targets": [
          {
            "expr": "histogram_quantile(0.99, rate(amb_delivery_duration_seconds_bucket[5m]))",
            "legendFormat": "p99",
            "refId": "A"
          },
          {
            "expr": "histogram_quantile(0.50, rate(amb_delivery_duration_seconds_bucket[5m]))",
            "legendFormat": "p50",
            "refId": "B"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "unit": "s"
          }
        }
      },
      {
        "id": 9,
        "type": "timeseries",
        "title": "Priority Lane Distribution",
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 0,
          "y": 20
        },
        "targets": [
          {
            "expr": "rate(amb_messages_published_total[5m])",
            "legendFormat": "{{priority}}",
            "refId": "A"
          }
        ],
        "options": {
          "legend": {
            "displayMode": "table"
          }
        }
      },
      {
        "id": 10,
        "type": "table",
        "title": "Dead Letter Queue",
        "gridPos": {
          "h": 8,
          "w": 12,
          "x": 12,
          "y": 20
        },
        "targets": [
          {
            "expr": "amb_dlq_messages_total",
            "format": "table",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "thresholds": {
              "steps": [
                {
                  "color": "green",
                  "value": null
                },
                {
                  "color": "red",
                  "value": 1
                }
              ]
            }
          }
        }
      },
      {
        "id": 11,
        "type": "stat",
        "title": "Broker Status",
        "gridPos": {
          "h": 4,
          "w": 8,
          "x": 0,
          "y": 28
        },
        "targets": [
          {
            "expr": "amb_broker_connected",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "mappings": [
              {
                "type": "value",
                "options": {
                  "1": {
                    "text": "Connected",
                    "color": "green"
                  }
                }
              },
              {
                "type": "value",
                "options": {
                  "0": {
                    "text": "Disconnected",
                    "color": "red"
                  }
                }
              }
            ]
          }
        }
      },
      {
        "id": 12,
        "type": "stat",
        "title": "Persistence Status",
        "gridPos": {
          "h": 4,
          "w": 8,
          "x": 8,
          "y": 28
        },
        "targets": [
          {
            "expr": "amb_persistence_enabled",
            "refId": "A"
          }
        ],
        "fieldConfig": {
          "defaults": {
            "mappings": [
              {
                "type": "value",
                "options": {
                  "1": {
                    "text": "Enabled",
                    "color": "green"
                  }
                }
              },
              {
                "type": "value",
                "options": {
                  "0": {
                    "text": "Disabled",
                    "color": "yellow"
                  }
                }
              }
            ]
          }
        }
      },
      {
        "id": 13,
        "type": "stat",
        "title": "Messages in WAL",
        "gridPos": {
          "h": 4,
          "w": 8,
          "x": 16,
          "y": 28
        },
        "targets": [
          {
            "expr": "amb_wal_messages_pending",
            "refId": "A"
          }
        ]
      }
    ]
  },
  "folderId": 0,
  "overwrite": true
}