AAnvio
Monitoring

Alerts

How to build alerting on top of Anvio's metrics endpoint and health checks — Anvio ships the signals, not a built-in alert manager.

2 min read

Anvio does not ship a built-in alerting engine. It exposes the raw signals — a Prometheus-format metrics endpoint, OpenTelemetry traces, and process health checks — and you wire alerting on top with whatever stack you already run.

No first-party alert manager

Per docs/13-observability.md, a bundled Prometheus + Grafana stack is a Phase 2 goal. Today there is no anvio alert command and no rules engine inside Anvio. The patterns below use external tooling against the signals Anvio already emits.

Signals available today

SignalSourceBest for
GET /api/metricspackages/observability/src/metrics-registry.tsToken usage, cost, MCP restarts
OTLP tracesinitObservability() in packages/observability/src/index.tsLatency, error spans, LLM call traces
GET /healthapps/api health controllerAPI liveness
http://localhost:8222/healthzNATS monitoring portBroker liveness (Level 3+)

Alerting on metrics (Prometheus)

Scrape GET /api/metrics with your existing Prometheus, then define rules against the exported series. For example, alert when hourly token cost crosses a threshold:

# prometheus/rules/anvio.yml
groups:
  - name: anvio
    rules:
      - alert: AnvioHighTokenCost
        expr: increase(anvio_token_cost_usd_total[1h]) > 5
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: 'Anvio token spend exceeded $5 in the last hour'
      - alert: AnvioMcpRestartsSpiking
        expr: increase(anvio_mcp_restarts_total[15m]) > 3
        for: 0m
        labels:
          severity: warning
        annotations:
          summary: 'An MCP server is restarting repeatedly'

Alerting on traces (Langfuse / OTLP backend)

Because Anvio ships spans over standard OTLP, alerting on error rate or p95 latency is a dashboard-and-threshold job in whatever backend ingests them (Langfuse, Jaeger + a metrics bridge, Grafana Tempo). See Tracing for how the pipeline is wired.

Liveness alerting

For a self-hosted Docker deployment, point an external uptime checker (or a Prometheus blackbox exporter) at GET /health and the NATS /healthz endpoint. If you run under Kubernetes, use these as readiness/liveness probes — see the Kubernetes roadmap.

TODO: When the Phase 2 Prometheus + Grafana bundle lands, replace the hand-rolled rules above with the shipped dashboard/alert definitions and document the anvio alerting surface.

Edit on GitHub

Last updated on

On this page