Observability
Dashboard
A live page of request rates, errors and latency, with no other server needed.
app.http(adapter) {
useMetrics()
useMetricsDashboard(path = "/_dashboard", service = "shop-api")
}Open http://localhost:8080/_dashboard. You get seven numbers and a table, refreshed every three seconds:
| Card | Means | Worry when |
|---|---|---|
| Requests/s | traffic in the last few seconds | it drops to 0 unexpectedly, or spikes |
| 5xx rate | share of requests that failed on the server | above a few percent |
| p50 | half of the requests were faster than this | rises: everything is slower |
| p95 | 95 of 100 requests were faster | rises while p50 stays flat: a few requests are slow |
| p99 | the slowest 1 in 100 | a very long tail means a slow dependency or lock |
| In flight | requests being handled right now | keeps growing: requests pile up faster than you finish them |
| Total | requests since start |
Below is a table of routes with their request and 5xx counts, busiest first; a route with failures is highlighted. This points you to the endpoint to look at first.
How it works, and what it is for
The page reads your own /metrics text every three seconds and computes the rates in the browser from the difference between two reads. The server keeps no extra data and does no extra work. That means:
- It shows what happened since you opened the page and only for the instance that answered. Reload and the history is gone.
- It needs nothing installed: use it in development, on a staging box, or to check a deployment right now.
- For history, several instances and alerts, use Prometheus and Grafana: the LGTM stack generates a Grafana dashboard with the same panels over time.
The percentiles are read from the histogram buckets, so they are bucket upper bounds (for example "p95 = 250 ms" means "at most 250 ms"), accurate enough to spot trends but not exact.
Keeping it private
The dashboard shows route names and traffic. Do not expose it publicly: mount it only when wanted (if (System.getenv("ENV") != "production") useMetricsDashboard()), or put it behind your network or a reverse proxy that requires a login.
Alert rules from the same place
GET /_dashboard/alerts.yml returns ready-made Prometheus alert rules for this service: see Production rules.