Skip to content

Metrics

Sia edited this page May 31, 2026 · 2 revisions

Metrics (Prometheus)

A zero-dep, admin-only Prometheus-compatible metrics endpoint at /metrics.

Scraping

/metrics is admin-only by design — the data exposes operational state about a single-user dev server. Two practical ways to scrape:

Direct Bearer

# prometheus.yml
scrape_configs:
  - job_name: vibe-coder-server
    scrape_interval: 30s
    metrics_path: /metrics
    bearer_token: <admin Bearer token from POST /api/auth/login>
    static_configs:
      - targets: ['vibe.local:17880']

The Bearer must belong to the admin user — same path as the SSR session check.

Reverse proxy basic-auth (nginx)

location /metrics {
    auth_basic           "metrics";
    auth_basic_user_file /etc/nginx/.htpasswd-metrics;
    proxy_pass           http://vibe-coder-server:17880/metrics;
    proxy_set_header     Cookie "vibe_session=<admin session token>";
}

You keep the gateway-level credentials separate from the in-app admin password and let the cookie forward auth.

Catalog

JVM (always present)

Metric Type Description
vibe_jvm_memory_used_bytes gauge Runtime.totalMemory() - Runtime.freeMemory()
vibe_jvm_memory_max_bytes gauge Runtime.maxMemory() (the -Xmx cap)
vibe_jvm_threads gauge Thread.activeCount()

Domain state (sampled live per scrape)

Metric Type Description
vibe_projects_total gauge Registered projects (excludes __scratch__)
vibe_users_total gauge All admin_users rows
vibe_devices_total gauge Active device tokens (Bearer + session cookies)
vibe_push_subscriptions_total gauge Browser Web Push subscriptions on file
vibe_console_sessions_active gauge Live main-console claude children
vibe_sub_agent_sessions_active gauge Live sub-agent claude children (across all projects)
vibe_rate_limit_buckets_active{bucket} gauge IPs in the limiter's bucket map; bucket="api" or "auth"

Event counters (reset on restart; Prometheus rate() handles the discontinuity)

Metric Type Description
vibe_build_total{status} counter Build outcomes. statussuccess / failed / cancelled
vibe_claude_usage_warn_total counter Claude usage threshold alerts fired
vibe_disk_usage_warn_total counter Disk usage threshold alerts fired
vibe_rate_limit_429_total{path_bucket} counter 429 rejections; path_bucket="api" or "auth"

Example dashboards

Useful queries against these metrics:

# Build success rate over the last hour
sum(rate(vibe_build_total{status="success"}[1h])) /
  sum(rate(vibe_build_total[1h])) * 100

# 95th percentile heap usage trend
quantile_over_time(0.95, vibe_jvm_memory_used_bytes[24h])

# Rate-limit rejection ratio (per bucket)
rate(vibe_rate_limit_429_total[5m])

Implementation notes

MetricsRegistry is a tiny in-process registry — no external client (micrometer, prometheus-simpleclient) added. Counters are LongAdder for cheap concurrent increment; gauges are () -> Number suppliers sampled at scrape time.

Notifiers.metrics is var and wired late in ServerMain (after MetricsRegistry is constructed) so the build / Claude usage / disk notifier paths can bump counters without Notifiers itself depending on the registry at construction.

Related

Clone this wiki locally