Documentation Index
Fetch the complete documentation index at: https://docs.langsight.dev/llms.txt
Use this file to discover all available pages before exploring further.
Overview
LangSight exposes two complementary monitoring surfaces:- Prometheus
/metricsendpoint — pull-based metrics for infrastructure dashboards and alerting rules - SSE live event feed (
GET /api/live/events) — push-based real-time events for dashboard UIs and custom integrations
Prometheus Metrics
Available metrics
| Metric | Type | Labels | Description |
|---|---|---|---|
langsight_http_requests_total | Counter | method, path, status | Total HTTP requests processed by the API |
langsight_http_request_duration_seconds | Histogram | method, path | Request duration with buckets: 10ms, 25ms, 50ms, 100ms, 250ms, 500ms, 1s, 2.5s, 5s, 10s |
langsight_spans_ingested_total | Counter | — | Total tool call spans ingested via /api/traces/spans and /api/traces/otlp |
langsight_active_sse_connections | Gauge | — | Number of currently connected SSE live feed clients |
langsight_health_checks_total | Counter | server, status | Total MCP health checks performed, labeled by server name and result status |
Path normalization
Thepath label in HTTP metrics uses normalized paths to keep cardinality bounded. UUIDs and long hex identifiers are collapsed to {id}:
/metrics, /api/liveness, /api/readiness) are excluded from instrumentation entirely.
Authentication
The/metrics endpoint requires a bearer token. Set the LANGSIGHT_METRICS_TOKEN environment variable before starting the API:
- If
LANGSIGHT_METRICS_TOKENis not set, the endpoint returns 404 (no body) so it does not fingerprint the deployment. - If the token is wrong or missing in the request, the endpoint returns 401 Unauthorized.
- Pass the token in every scrape request using the
Authorization: Bearer <token>header.
Scrape configuration
Add the following job to yourprometheus.yml, including the authorization block:
Verify the endpoint
Grafana Dashboard Tips
Recommended panels
| Panel | PromQL | Visualization |
|---|---|---|
| Request rate | rate(langsight_http_requests_total[5m]) | Time series, stacked by path |
| Error rate | sum(rate(langsight_http_requests_total{status=~"5.."}[5m])) / sum(rate(langsight_http_requests_total[5m])) | Stat panel, threshold: red > 1% |
| p99 latency | histogram_quantile(0.99, rate(langsight_http_request_duration_seconds_bucket[5m])) | Time series, by path |
| Span ingestion rate | rate(langsight_spans_ingested_total[5m]) | Stat panel (spans/sec) |
| Active SSE clients | langsight_active_sse_connections | Gauge panel |
| Health check rate | rate(langsight_health_checks_total[5m]) | Time series, by server |
| Health check failures | rate(langsight_health_checks_total{status="down"}[5m]) | Time series, by server |
Alert rules (Grafana Alerting)
Dashboard JSON
A pre-built Grafana dashboard JSON is planned for a future release. In the meantime, create a dashboard manually using the PromQL queries above, or import the panels into an existing infrastructure dashboard.SSE Live Event Feed
How it works
GET /api/live/events opens a Server-Sent Events stream. The server pushes events as they happen — no polling required.
Authentication: This endpoint requires the same authentication as all other API routes (X-API-Key header or session proxy headers).
Events pushed:
| Event type | Triggered by | Payload fields |
|---|---|---|
span:new | Span ingestion via /api/traces/spans | session_id, agent_name, server_name, tool_name, status, latency_ms |
health:check | Health check completion | server_name, status, latency_ms |
- Keepalive comments (
: keepalive) sent every 15 seconds to prevent proxy/load-balancer timeouts - Maximum 200 concurrent clients — the 201st connection receives an
event: errorand closes - Each client has a 50-event buffer; if the client is slower than the event rate, the oldest event is dropped
- The browser
EventSourceAPI reconnects automatically on disconnection
JavaScript example (browser)
When using the LangSight dashboard, the live event feed is connected automatically. The example above is for custom integrations or external dashboards that want to receive real-time events from LangSight.
Python example (httpx-sse)
curl example
-N flag disables output buffering so events appear immediately.
Dashboard Integration
The LangSight Next.js dashboard uses both monitoring surfaces:- Polling (existing): SWR fetchers poll REST API endpoints at 5s (health) and 30s (metrics) intervals for page-level data
- SSE (new): The dashboard connects to
GET /api/live/eventsfor instant notifications — span ingestion events trigger session list refreshes and health check events update server status indicators without waiting for the next poll cycle
Architecture
Single-instance limitation
TheSSEBroadcaster is an in-memory asyncio pub/sub. Events published on one API instance are not visible to SSE clients connected to a different instance. For single-instance deployments (the default Docker Compose setup), this is not a limitation.
For multi-instance horizontal scaling, a Redis pub/sub layer can be added behind the same SSEBroadcaster interface. This is planned for a future release when horizontal scaling becomes a requirement.