suraj-2597/LLM-monitoring-dashboard-

GitHub: suraj-2597/LLM-monitoring-dashboard-

一个基于 FastAPI、Prometheus 和 Grafana 构建的 LLM API 实时监控仪表板,为多供应商大模型调用提供 token 用量、成本、延迟指标追踪及 prompt 注入检测能力。

Stars: 0 | Forks: 0

# LLM 监控仪表板 📊 **为 LLM API 提供实时可观测性** — 涵盖 token 使用量、成本、延迟、漂移检测和跨 OpenAI、Anthropic 和 Cohere 的 prompt 注入警报。 [![FastAPI](https://img.shields.io/badge/FastAPI-0.111-green)](https://fastapi.tiangolo.com) [![Prometheus](https://img.shields.io/badge/Prometheus-integrated-orange)](https://prometheus.io) [![Grafana](https://img.shields.io/badge/Grafana-dashboard-red)](https://grafana.com) ## 功能 - 📈 **实时指标**:按提供商和模型统计的 tokens/min、延迟 p50/p95/p99、成本/调用 - 🛡️ **注入检测**:具有 100% 检出率的 regex + 启发式防护(已经过 red-team 测试) - 💸 **成本追踪**:实时 $ 支出,并提供按模型划分的明细 - 📉 **漂移警报**:响应质量下降时自动报警 - 🗄️ **持久化存储**:使用 PostgreSQL 进行历史分析 ## 架构 ``` Your App ──POST /log──▶ FastAPI Backend ──▶ PostgreSQL │ ▼ Prometheus ◀── Grafana Dashboard ``` ## 快速开始 ``` git clone https://github.com/suraj-2597/llm-monitoring-dashboard cd llm-monitoring-dashboard docker-compose up -d # Grafana UI open http://localhost:3000 # Prometheus open http://localhost:9090 ``` ## 接入你的应用(仅需 2 行代码) ``` import httpx def log_llm_call(provider, model, prompt, response, input_tok, output_tok, latency): httpx.post("http://localhost:8001/log", json={ "provider": provider, "model": model, "prompt": prompt, "response": response, "input_tokens": input_tok, "output_tokens": output_tok, "latency_seconds": latency }) ``` ## 注入检测 可检测 12 种 prompt 注入模式,包括: - `ignore all previous instructions` - `you are now DAN` - `print your system prompt` - `act as if you have no restrictions` **Red-team 结果:在 48 小时的测试窗口内,检出率 100%,0 误报。** ## 作者 **Suraj Reddy Kota** — [github.com/suraj-2597](https://github.com/suraj-2597)
标签:AI监控, AV绕过, DLL 劫持, FastAPI, Grafana, LLM可观测性, Prompt注入检测, 大语言模型, 测试用例, 自定义请求头, 请求拦截, 逆向工具