{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 0,
  "id": 1,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "datasource": {
        "type": "sqlite",
        "uid": "performance-metrics"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Duration (ms)",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "none",
            "hideFrom": {
              "tooltip": false,
              "viz": false,
              "legend": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "max": 60000,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 30000
              }
            ]
          },
          "unit": "ms"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "Agent Startup SLA"
            },
            "properties": [
              {
                "id": "color",
                "value": {
                  "mode": "fixed",
                  "fixedColor": "green"
                }
              },
              {
                "id": "custom.lineStyle",
                "value": {
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 2
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 0
      },
      "id": 2,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT $__time(timestamp), avg(duration_ms) as \"Agent Startup\"\nFROM performance_metrics\nWHERE operation = 'agent_startup' AND timestamp > $__from AND timestamp < $__to\nGROUP BY DATE(timestamp), HOUR(timestamp)\nORDER BY timestamp ASC",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration_ms"
                ],
                "type": "field"
              }
            ]
          ],
          "table": "performance_metrics",
          "timeColumn": "timestamp",
          "where": [
            {
              "name": "operation",
              "params": [
                "agent_startup"
              ],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Agent Startup Performance Over Time",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "sqlite",
        "uid": "performance-metrics"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [
            {
              "options": {
                "result": {
                  "color": "green",
                  "index": 1,
                  "text": "Compliant"
                }
              },
              "type": "value"
            }
          ],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 95
              },
              {
                "color": "green",
                "value": 99
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 0
      },
      "id": 3,
      "options": {
        "colorMode": "background",
        "graphMode": "area",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "values": false,
          "fields": "",
          "calcs": [
            "lastNotNull"
          ]
        },
        "textMode": "auto"
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  operation,\n  ROUND(100.0 * SUM(CASE WHEN is_sla_violation = 0 THEN 1 ELSE 0 END) / COUNT(*), 2) as compliance\nFROM performance_metrics\nWHERE timestamp > $__from AND timestamp < $__to\nGROUP BY operation",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "field"
              }
            ]
          ],
          "table": "performance_metrics",
          "where": []
        }
      ],
      "title": "SLA Compliance by Operation (Last 24h)",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "sqlite",
        "uid": "performance-metrics"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Duration (ms)",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "none",
            "hideFrom": {
              "tooltip": false,
              "viz": false,
              "legend": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "max": 15000,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 10000
              }
            ]
          },
          "unit": "ms"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 8
      },
      "id": 4,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT $__time(timestamp), avg(duration_ms) as \"Query Execution\"\nFROM performance_metrics\nWHERE operation = 'query_execution' AND timestamp > $__from AND timestamp < $__to\nGROUP BY DATE(timestamp), HOUR(timestamp)\nORDER BY timestamp ASC",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration_ms"
                ],
                "type": "field"
              }
            ]
          ],
          "table": "performance_metrics",
          "timeColumn": "timestamp",
          "where": [
            {
              "name": "operation",
              "params": [
                "query_execution"
              ],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Query Execution Performance Over Time",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "sqlite",
        "uid": "performance-metrics"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "mappings": [],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 50
              },
              {
                "color": "green",
                "value": 95
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 8
      },
      "id": 5,
      "options": {
        "colorMode": "background",
        "graphMode": "none",
        "justifyMode": "auto",
        "orientation": "auto",
        "reduceOptions": {
          "values": false,
          "fields": "",
          "calcs": [
            "lastNotNull"
          ]
        },
        "textMode": "auto"
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  SUM(CASE WHEN is_sla_violation = 1 THEN 1 ELSE 0 END) as violations\nFROM performance_metrics\nWHERE timestamp > $__from AND timestamp < $__to",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "field"
              }
            ]
          ],
          "table": "performance_metrics",
          "where": []
        }
      ],
      "title": "Total SLA Violations (Last 24h)",
      "type": "stat"
    },
    {
      "datasource": {
        "type": "sqlite",
        "uid": "performance-metrics"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Duration (ms)",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 10,
            "gradientMode": "none",
            "hideFrom": {
              "tooltip": false,
              "viz": false,
              "legend": false
            },
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "max": 90000,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 60000
              }
            ]
          },
          "unit": "ms"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 16
      },
      "id": 6,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "max",
            "min"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT $__time(timestamp), avg(duration_ms) as \"Skill Execution\"\nFROM performance_metrics\nWHERE operation = 'skill_execution' AND timestamp > $__from AND timestamp < $__to\nGROUP BY DATE(timestamp), HOUR(timestamp)\nORDER BY timestamp ASC",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "duration_ms"
                ],
                "type": "field"
              }
            ]
          ],
          "table": "performance_metrics",
          "timeColumn": "timestamp",
          "where": [
            {
              "name": "operation",
              "params": [
                "skill_execution"
              ],
              "type": "macro"
            }
          ]
        }
      ],
      "title": "Skill Execution Performance Over Time",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "sqlite",
        "uid": "performance-metrics"
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Compliance (%)",
            "axisPlacement": "auto",
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 15,
            "gradientMode": "opacity",
            "hideFrom": {
              "tooltip": false,
              "viz": false,
              "legend": false
            },
            "lineInterpolation": "smooth",
            "lineWidth": 2,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "auto",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "line"
            }
          },
          "mappings": [],
          "max": 100,
          "min": 0,
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "red",
                "value": null
              },
              {
                "color": "yellow",
                "value": 95
              },
              {
                "color": "green",
                "value": 99
              }
            ]
          },
          "unit": "percent"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 16
      },
      "id": 7,
      "options": {
        "legend": {
          "calcs": [
            "mean",
            "last"
          ],
          "displayMode": "table",
          "placement": "right",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "format": "time_series",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  $__time(DATE(timestamp)) as time,\n  operation,\n  ROUND(100.0 * SUM(CASE WHEN is_sla_violation = 0 THEN 1 ELSE 0 END) / COUNT(*), 2) as compliance\nFROM performance_metrics\nWHERE timestamp > $__from AND timestamp < $__to\nGROUP BY DATE(timestamp), operation\nORDER BY time ASC",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "field"
              }
            ]
          ],
          "table": "performance_metrics",
          "where": []
        }
      ],
      "title": "SLA Compliance Trend (Daily)",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "sqlite",
        "uid": "performance-metrics"
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "align": "auto",
            "cellOptions": {
              "type": "auto"
            },
            "inspect": false
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          }
        },
        "overrides": [
          {
            "matcher": {
              "id": "byName",
              "options": "level"
            },
            "properties": [
              {
                "id": "custom.displayMode",
                "value": "color-background"
              },
              {
                "id": "mappings",
                "value": [
                  {
                    "options": {
                      "critical": {
                        "color": "dark-red",
                        "index": 2
                      },
                      "info": {
                        "color": "light-blue",
                        "index": 0
                      },
                      "warning": {
                        "color": "dark-yellow",
                        "index": 1
                      }
                    },
                    "type": "value"
                  }
                ]
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 24
      },
      "id": 8,
      "options": {
        "footer": {
          "countRows": false,
          "fields": "",
          "reducer": [
            "sum"
          ],
          "show": false
        },
        "showHeader": true,
        "sortBy": [
          {
            "desc": true,
            "displayName": "timestamp"
          }
        ]
      },
      "pluginVersion": "10.0.0",
      "targets": [
        {
          "format": "table",
          "group": [],
          "hide": false,
          "metricColumn": "none",
          "rawQuery": true,
          "rawSql": "SELECT\n  timestamp,\n  operation,\n  level,\n  message,\n  resolved_at\nFROM performance_alerts\nWHERE timestamp > $__from AND timestamp < $__to\nORDER BY timestamp DESC\nLIMIT 100",
          "refId": "A",
          "select": [
            [
              {
                "params": [
                  "id"
                ],
                "type": "field"
              }
            ]
          ],
          "table": "performance_alerts",
          "where": []
        }
      ],
      "title": "Recent Performance Alerts",
      "type": "table"
    }
  ],
  "refresh": "30s",
  "schemaVersion": 38,
  "style": "dark",
  "tags": [
    "performance",
    "sla",
    "monitoring"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "selected": false,
          "text": "24h",
          "value": "24h"
        },
        "hide": 0,
        "includeAll": false,
        "label": "Time Range",
        "multi": false,
        "name": "time_range",
        "options": [
          {
            "selected": false,
            "text": "1h",
            "value": "1h"
          },
          {
            "selected": true,
            "text": "24h",
            "value": "24h"
          },
          {
            "selected": false,
            "text": "7d",
            "value": "7d"
          },
          {
            "selected": false,
            "text": "30d",
            "value": "30d"
          }
        ],
        "query": "1h, 24h, 7d, 30d",
        "queryValue": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "custom"
      }
    ]
  },
  "time": {
    "from": "now-24h",
    "to": "now"
  },
  "timepicker": {},
  "timezone": "",
  "title": "Performance Monitoring Overview",
  "uid": "performance-overview",
  "version": 1,
  "weekStart": ""
}
