{
  "uid": "mcp-usage-selfhosted",
  "title": "MCP Usage",
  "tags": [
    "mcp",
    "fusion",
    "gateway"
  ],
  "schemaVersion": 39,
  "version": 1,
  "editable": true,
  "graphTooltip": 1,
  "time": {
    "from": "now-7d",
    "to": "now"
  },
  "timezone": "browser",
  "refresh": "5m",
  "templating": {
    "list": [
      {
        "name": "datasource",
        "label": "Prometheus data source",
        "type": "datasource",
        "query": "prometheus",
        "current": {},
        "hide": 0,
        "refresh": 1
      },
      {
        "name": "namespace",
        "label": "Namespace",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "${datasource}"
        },
        "query": {
          "query": "label_values(gateway_request_time_secs_count{routeId=\"mcp-server\"}, namespace)",
          "refId": "StandardVariableQuery"
        },
        "refresh": 2,
        "sort": 1,
        "includeAll": true,
        "allValue": ".*",
        "multi": true,
        "current": {
          "text": "All",
          "value": "$__all"
        },
        "hide": 0
      }
    ]
  },
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "grafana",
          "uid": "-- Grafana --"
        },
        "enable": true,
        "hide": true,
        "name": "Annotations & Alerts",
        "type": "dashboard"
      }
    ]
  },
  "panels": [
    {
      "id": 1,
      "type": "row",
      "title": "MCP Usage \u2014 Overview",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "panels": []
    },
    {
      "id": 2,
      "type": "stat",
      "title": "Total MCP Requests",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 0,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "unit": "short",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "decimals": 0
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "orientation": "auto",
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "textMode": "auto"
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(increase(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__range]))",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "id": 3,
      "type": "stat",
      "title": "Request Rate",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 6,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "unit": "reqps",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "decimals": 3
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "orientation": "auto",
        "colorMode": "value",
        "graphMode": "area",
        "justifyMode": "auto",
        "textMode": "auto"
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(rate(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval]))",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "id": 4,
      "type": "stat",
      "title": "Error Rate",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 12,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "unit": "percent",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 1
              },
              {
                "color": "red",
                "value": 5
              }
            ]
          },
          "decimals": 2
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "orientation": "auto",
        "colorMode": "background",
        "graphMode": "area",
        "justifyMode": "auto",
        "textMode": "auto"
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "100 * (sum(rate(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\",outcome=~\"CLIENT_ERROR|SERVER_ERROR\"}[$__rate_interval])) or vector(0)) / sum(rate(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval]))",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "id": 5,
      "type": "stat",
      "title": "Avg Latency",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 4,
        "w": 6,
        "x": 18,
        "y": 1
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "thresholds"
          },
          "unit": "ms",
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "yellow",
                "value": 500
              },
              {
                "color": "red",
                "value": 2000
              }
            ]
          },
          "decimals": 1
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "orientation": "auto",
        "colorMode": "background",
        "graphMode": "area",
        "justifyMode": "auto",
        "textMode": "auto"
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "1000 * sum(rate(gateway_request_time_secs_sum{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval])) / sum(rate(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval]))",
          "legendFormat": "__auto",
          "range": false,
          "instant": true,
          "refId": "A"
        }
      ]
    },
    {
      "id": 6,
      "type": "row",
      "title": "Latency",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 5
      },
      "panels": []
    },
    {
      "id": 7,
      "type": "timeseries",
      "title": "MCP Latency Percentiles (p50 / p95 / p99)",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 6
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "lineWidth": 2,
            "fillOpacity": 10,
            "gradientMode": "opacity",
            "spanNulls": false,
            "showPoints": "never",
            "pointSize": 5,
            "stacking": {
              "mode": "none",
              "group": "A"
            },
            "axisPlacement": "auto",
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "unit": "ms",
          "color": {
            "mode": "palette-classic"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "mappings": []
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": [],
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "1000 * histogram_quantile(0.50, sum by (le) (rate(gateway_request_time_secs_bucket{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval])))",
          "legendFormat": "p50",
          "range": true,
          "instant": false,
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "1000 * histogram_quantile(0.95, sum by (le) (rate(gateway_request_time_secs_bucket{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval])))",
          "legendFormat": "p95",
          "range": true,
          "instant": false,
          "refId": "B"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "1000 * histogram_quantile(0.99, sum by (le) (rate(gateway_request_time_secs_bucket{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval])))",
          "legendFormat": "p99",
          "range": true,
          "instant": false,
          "refId": "C"
        }
      ]
    },
    {
      "id": 8,
      "type": "timeseries",
      "title": "Average Latency",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 12,
        "y": 6
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "lineWidth": 2,
            "fillOpacity": 10,
            "gradientMode": "opacity",
            "spanNulls": false,
            "showPoints": "never",
            "pointSize": 5,
            "stacking": {
              "mode": "none",
              "group": "A"
            },
            "axisPlacement": "auto",
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "unit": "ms",
          "color": {
            "mode": "palette-classic"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "mappings": []
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": [],
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "1000 * sum(rate(gateway_request_time_secs_sum{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval])) / sum(rate(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval]))",
          "legendFormat": "avg latency",
          "range": true,
          "instant": false,
          "refId": "A"
        }
      ]
    },
    {
      "id": 9,
      "type": "row",
      "title": "Traffic & Errors",
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 14
      },
      "panels": []
    },
    {
      "id": 10,
      "type": "timeseries",
      "title": "Total MCP Requests Over Time",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 24,
        "x": 0,
        "y": 15
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "lineWidth": 2,
            "fillOpacity": 20,
            "gradientMode": "opacity",
            "spanNulls": false,
            "showPoints": "never",
            "pointSize": 5,
            "stacking": {
              "mode": "none",
              "group": "A"
            },
            "axisPlacement": "auto",
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "unit": "short",
          "color": {
            "mode": "palette-classic"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "mappings": []
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": [],
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum(increase(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__interval]))",
          "legendFormat": "total requests",
          "range": true,
          "instant": false,
          "refId": "A"
        }
      ]
    },
    {
      "id": 11,
      "type": "timeseries",
      "title": "MCP Request Rate by Status Code",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 12,
        "x": 0,
        "y": 23
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "lineWidth": 2,
            "fillOpacity": 10,
            "gradientMode": "opacity",
            "spanNulls": false,
            "showPoints": "never",
            "pointSize": 5,
            "stacking": {
              "mode": "normal",
              "group": "A"
            },
            "axisPlacement": "auto",
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "unit": "reqps",
          "color": {
            "mode": "palette-classic"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "mappings": []
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "table",
          "placement": "bottom",
          "calcs": [
            "lastNotNull",
            "max"
          ],
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum by (httpStatusCode) (rate(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval]))",
          "legendFormat": "{{httpStatusCode}}",
          "range": true,
          "instant": false,
          "refId": "A"
        }
      ]
    },
    {
      "id": 12,
      "type": "timeseries",
      "title": "Error Rate (%)",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 6,
        "x": 12,
        "y": 23
      },
      "fieldConfig": {
        "defaults": {
          "custom": {
            "drawStyle": "line",
            "lineInterpolation": "smooth",
            "lineWidth": 2,
            "fillOpacity": 20,
            "gradientMode": "opacity",
            "spanNulls": false,
            "showPoints": "never",
            "pointSize": 5,
            "stacking": {
              "mode": "none",
              "group": "A"
            },
            "axisPlacement": "auto",
            "scaleDistribution": {
              "type": "linear"
            }
          },
          "unit": "percent",
          "color": {
            "mode": "palette-classic"
          },
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "mappings": []
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": [],
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "desc"
        }
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "100 * (sum(rate(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\",outcome=~\"CLIENT_ERROR|SERVER_ERROR\"}[$__rate_interval])) or vector(0)) / sum(rate(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__rate_interval]))",
          "legendFormat": "error %",
          "range": true,
          "instant": false,
          "refId": "A"
        }
      ]
    },
    {
      "id": 13,
      "type": "piechart",
      "title": "Requests by Outcome",
      "datasource": {
        "type": "prometheus",
        "uid": "${datasource}"
      },
      "gridPos": {
        "h": 8,
        "w": 6,
        "x": 18,
        "y": 23
      },
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "unit": "short",
          "custom": {
            "hideFrom": {
              "tooltip": false,
              "viz": false,
              "legend": false
            }
          },
          "mappings": []
        },
        "overrides": []
      },
      "options": {
        "reduceOptions": {
          "calcs": [
            "lastNotNull"
          ],
          "fields": "",
          "values": false
        },
        "pieType": "donut",
        "tooltip": {
          "mode": "single",
          "sort": "none"
        },
        "legend": {
          "displayMode": "table",
          "placement": "right",
          "showLegend": true,
          "values": [
            "value",
            "percent"
          ]
        },
        "displayLabels": [
          "percent"
        ]
      },
      "targets": [
        {
          "datasource": {
            "type": "prometheus",
            "uid": "${datasource}"
          },
          "editorMode": "code",
          "expr": "sum by (outcome) (increase(gateway_request_time_secs_count{routeId=\"mcp-server\",namespace=~\"$namespace\"}[$__range]))",
          "legendFormat": "{{outcome}}",
          "range": false,
          "instant": true,
          "refId": "A"
        }
      ]
    }
  ]
}