Health and Metrics Internals
-
Liveness/Readiness
Handlers return fine-grained status with DB probes.
-
Prometheus
Export standard and custom app metrics.
-
DB Exporter
PostgreSQL exporter complements app metrics.
Scrape Intervals
Start with 15s scraping and tighten as necessary to capture spikes while controlling overhead.
Metric Names
Prefix application metrics with tribrid_ and prefer corpus-level labels.
Cardinality
Avoid labels that grow per-query.
flowchart TB
App --> METRICS["/metrics"]
METRICS --> Prom["Prometheus"]
Postgres --> PExp["postgres-exporter"]
PExp --> Prom Access Examples
import httpx
assert httpx.get("http://localhost:8000/health").status_code == 200
assert httpx.get("http://localhost:8000/ready").status_code == 200
print(httpx.get("http://localhost:8000/metrics").text.splitlines()[:5])
curl -sS http://localhost:8000/health
curl -sS http://localhost:8000/ready
curl -sS http://localhost:8000/metrics | head -n 20
await fetch('/health').then(r => r.ok || Promise.reject('down'))
await fetch('/ready').then(r => r.ok || Promise.reject('not ready'))
const sample = await (await fetch('/metrics')).text();
console.log(sample.split('\n').slice(0, 5));
Observability
Combine /metrics with logs and tracing for a complete operational picture.