Skip to content

Metrics & Monitoring

Every JustAPI application exposes Prometheus-compatible metrics at /metrics:

Terminal window
curl http://localhost:8000/metrics
Metric Type Description
requests_total Counter Total requests by route and status
request_duration_seconds Histogram Request latency (p50, p95, p99, p999)
inbound_bytes_total Counter Total bytes received
outbound_bytes_total Counter Total bytes sent
connections_active Gauge Currently active connections
errors_total Counter Error count by type
scrape_configs:
- job_name: 'justapi'
static_configs:
- targets: ['localhost:8000']
metrics_path: /metrics
scrape_interval: 15s

Key panels to create:

  1. Request Raterate(requests_total[1m]) by route
  2. Latencyhistogram_quantile(0.99, rate(request_duration_seconds_bucket[5m]))
  3. Error Ratiorate(errors_total[5m]) / rate(requests_total[5m])
  4. Active Connectionsconnections_active
groups:
- name: justapi
rules:
- alert: HighErrorRate
expr: rate(errors_total[5m]) / rate(requests_total[5m]) > 0.05
for: 5m
labels: { severity: critical }
- alert: HighLatency
expr: histogram_quantile(0.99, rate(request_duration_seconds_bucket[5m])) > 1
for: 5m
labels: { severity: warning }

JustAPI supports webhook-based alerting:

app.enable_alerting(
slack_webhook="https://hooks.slack.com/services/...",
pagerduty_key="...",
)