Metrics & Monitoring
Metrics Endpoint
Section titled “Metrics Endpoint”Every JustAPI application exposes Prometheus-compatible metrics at /metrics:
curl http://localhost:8000/metricsAvailable Metrics
Section titled “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
Section titled “Prometheus Scrape Configuration”scrape_configs: - job_name: 'justapi' static_configs: - targets: ['localhost:8000'] metrics_path: /metrics scrape_interval: 15sGrafana Dashboard
Section titled “Grafana Dashboard”Key panels to create:
- Request Rate —
rate(requests_total[1m])by route - Latency —
histogram_quantile(0.99, rate(request_duration_seconds_bucket[5m])) - Error Ratio —
rate(errors_total[5m]) / rate(requests_total[5m]) - Active Connections —
connections_active
Alerting Rules
Section titled “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
Section titled “Built-in Alerting”JustAPI supports webhook-based alerting:
app.enable_alerting( slack_webhook="https://hooks.slack.com/services/...", pagerduty_key="...",)See Also
Section titled “See Also”- OpenTelemetry — Distributed tracing
- Structured Logging — Log configuration
- Health Checks — Health endpoints