justapi — /docs

Metrics Endpoint

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

curl http://localhost:8000/metrics

Available 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

Prometheus Scrape Configuration

scrape_configs:
  - job_name: 'justapi'
    static_configs:
      - targets: ['localhost:8000']
    metrics_path: /metrics
    scrape_interval: 15s

Grafana Dashboard

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

Alerting Rules

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 }

Built-in Alerting

JustAPI supports webhook-based alerting:

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

See Also

JustAPI v2.0.9 — Open Source MIT License · Built with WebTUI · GitHub

NORMAL master justapi/docs
utf-8 Top 1:1