Observability
Overview
Know what your application is doing in production, and why.
When something goes wrong at 3 a.m. you need to answer, quickly: is it broken, where, and why? Observability is having the data to answer that without guessing. It rests on four kinds of data, and each answers a different question:
| Data | Looks like | Answers | Kest page |
|---|---|---|---|
| Metrics | numbers over time | "Is something wrong? How bad?" (error rate, latency, memory) | Metrics |
| Traces | the path of one request across services | "Where is it slow or failing?" | OpenTelemetry, Distributed tracing |
| Logs | lines of text | "What happened, in detail?" | LGTM stack |
| Errors | grouped exceptions with stack traces | "What crashed, and who was affected?" | Error monitoring |
Plus two more things that are not data but act on it: health checks (is this instance fit to receive traffic?) and alerts (wake a human when a metric crosses a line).
Loading diagram…
Start small, in this order
- Health checks and error monitoring (a few lines each). You learn when it is down and what crashed.
- Metrics and the built-in dashboard. You see traffic, errors and latency.
- Alerts on error rate and latency (Production rules). You are told instead of having to look.
- Logs and traces together in Grafana, the LGTM stack, as soon as you have more than one service or one bug you cannot explain.
// step 1 and 2 in one place
Kest.run<AppModule> { import(SentryModule.forRoot { dsn = System.getenv("SENTRY_DSN") }, MetricsModule.forRoot { jvm = true }) }
app.http(adapter) {
useHealth("/health/ready") { ormConnections(orm) }
useMetrics()
useMetricsDashboard()
}Words you will meet
- Instrumentation: code that produces observability data. Kest instruments HTTP, queues, schedules and more for you; you add your own (
@Traced, a counter). - Collector: a service that receives data from many applications and forwards it to storage (OpenTelemetry Collector, Grafana Alloy).
- Cardinality: how many different values a label has. Keep it low (Metrics).
- SLO: a target you promise, such as "99.9% of requests succeed". Alerts are best tied to one.
- Sampling: keeping only a fraction of traces to save cost.
See Choosing an APM for where to send the data.