{
  "uid": "aibrix-routing-study",
  "title": "AIBrix 路由实测 · 决策、缓存与等待",
  "schemaVersion": 39,
  "version": 1,
  "style": "light",
  "tags": [
    "AIBrix",
    "routing-study",
    "L20"
  ],
  "timezone": "Asia/Shanghai",
  "refresh": "10s",
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "panels": [
    {
      "id": 1,
      "title": "客户端 TTFT P95",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 0,
        "y": 0,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "histogram_quantile(.95,sum by(le,phase)(rate(routing_study_ttft_seconds_bucket{job=\"qwen-routing-study\",phase=~\"$phase\"}[1m])))",
          "legendFormat": "{{phase}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 2,
      "title": "完整流与达标请求率",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 12,
        "y": 0,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by(result)(rate(routing_study_requests_total{job=\"qwen-routing-study\",phase=~\"$phase\"}[1m]))",
          "legendFormat": "{{result}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        },
        {
          "refId": "B",
          "expr": "sum(rate(routing_study_good_requests_total{job=\"qwen-routing-study\",phase=~\"$phase\"}[1m]))",
          "legendFormat": "达标",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "reqps",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 3,
      "title": "各副本运行 / 等待",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 0,
        "y": 8,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by(node_alias)(vllm:num_requests_running{job=\"qwen-lab-engine\",model_name=\"qwen38-aibrix-lab\"})",
          "legendFormat": "{{node_alias}} 运行",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        },
        {
          "refId": "B",
          "expr": "sum by(node_alias)(vllm:num_requests_waiting{job=\"qwen-lab-engine\",model_name=\"qwen38-aibrix-lab\"})",
          "legendFormat": "{{node_alias}} 等待",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 4,
      "title": "引擎实际前缀 Token 命中率",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 12,
        "y": 8,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by(node_alias)(rate(vllm:prefix_cache_hits_total{job=\"qwen-lab-engine\",model_name=\"qwen38-aibrix-lab\"}[1m]))/sum by(node_alias)(rate(vllm:prefix_cache_queries_total{job=\"qwen-lab-engine\",model_name=\"qwen38-aibrix-lab\"}[1m]))",
          "legendFormat": "{{node_alias}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percentunit",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 5,
      "title": "AIBrix 前缀选择方式",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 0,
        "y": 16,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by(selection)(rate(aibrix_prefix_cache_routing_selection_total{job=\"qwen-lab-gateway\",model=\"qwen38-aibrix-lab\"}[1m]))",
          "legendFormat": "{{selection}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "reqps",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 6,
      "title": "AIBrix 路由前缀匹配分档",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 12,
        "y": 16,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by(match_percent_bucket)(rate(aibrix_prefix_cache_routing_decisions_total{job=\"qwen-lab-gateway\",model=\"qwen38-aibrix-lab\"}[1m]))",
          "legendFormat": "{{match_percent_bucket}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "reqps",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 7,
      "title": "各副本输出 Token/s",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 0,
        "y": 24,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by(node_alias)(rate(vllm:generation_tokens_total{job=\"qwen-lab-engine\",model_name=\"qwen38-aibrix-lab\"}[1m]))",
          "legendFormat": "{{node_alias}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "suffix:Token/s",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 8,
      "title": "客户端平均 TPOT P95",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 12,
        "y": 24,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "histogram_quantile(.95,sum by(le,phase)(rate(routing_study_tpot_seconds_bucket{job=\"qwen-routing-study\",phase=~\"$phase\"}[1m])))",
          "legendFormat": "{{phase}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "s",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 9,
      "title": "客户端在途请求",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 0,
        "y": 32,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "sum by(phase)(routing_study_inflight{job=\"qwen-routing-study\",phase=~\"$phase\"})",
          "legendFormat": "{{phase}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "short",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    },
    {
      "id": 10,
      "title": "GPU 利用率 · 测试卡",
      "type": "timeseries",
      "datasource": {
        "type": "prometheus",
        "uid": "prometheus"
      },
      "gridPos": {
        "x": 12,
        "y": 32,
        "w": 12,
        "h": 8
      },
      "targets": [
        {
          "refId": "A",
          "expr": "max by(node_alias,gpu)(DCGM_FI_DEV_GPU_UTIL{job=\"qwen-lab-dcgm\",pod_name=~\"qwen38-aibrix-lab-.*\"})",
          "legendFormat": "{{node_alias}} / GPU{{gpu}}",
          "datasource": {
            "type": "prometheus",
            "uid": "prometheus"
          }
        }
      ],
      "fieldConfig": {
        "defaults": {
          "unit": "percent",
          "custom": {
            "lineWidth": 2,
            "fillOpacity": 5,
            "spanNulls": false
          }
        },
        "overrides": []
      },
      "options": {
        "legend": {
          "displayMode": "list",
          "placement": "bottom",
          "calcs": []
        },
        "tooltip": {
          "mode": "multi"
        }
      }
    }
  ],
  "templating": {
    "list": [
      {
        "name": "phase",
        "label": "阶段",
        "type": "query",
        "datasource": {
          "type": "prometheus",
          "uid": "prometheus"
        },
        "query": "label_values(routing_study_requests_total, phase)",
        "refresh": 1,
        "includeAll": true,
        "allValue": ".*",
        "current": {
          "text": "All",
          "value": "$__all"
        }
      }
    ]
  }
}