teacher
Sign in

Observability and Security

See what a running system is doing with logs, metrics and traces, and secure it with authentication, OAuth 2.0, JWTs, TLS and secret management.

35 min4 interactive

Part 1: Observability

Observability is how well you can understand what a system is doing from the outside, using the data it emits. When something breaks at 3 a.m., you need answers without logging into servers. Three kinds of data work together.

SignalWhat it isAnswersTools
LogsTimestamped records of eventsWhat exactly happened to this request?Elasticsearch + Kibana, Loki, CloudWatch Logs
MetricsNumbers sampled over timeIs something wrong, and how bad?Prometheus + Grafana, Datadog
TracesThe path of one request across servicesWhere did the time go?Jaeger, Zipkin, Tempo

Use metrics to notice, traces to locate, logs to explain.

Logs

  • Write structured logs (JSON with fields) instead of free text, so they can be searched: {"level":"error","order_id":"o-17","msg":"payment timeout"}.
  • Include a request id or trace id in every line, so one request can be followed across services.
  • Never log passwords, tokens or card numbers.
  • Logs are expensive at volume. Sample or lower the level for noisy paths.

Metrics

Watch the RED signals for each service:

  • Rate: requests per second.
  • Errors: share of failed requests.
  • Duration: how long requests take, as percentiles.

A percentile says what share of requests were faster than a value. p99 latency of 800 ms means 99% of requests took 800 ms or less and 1% took longer. Averages hide the slow tail, so alert on p95 or p99.

Estimate
A page makes 100 backend calls in parallel. Each call is slower than its p99 threshold 1% of the time, independently. What percent of page loads see at least one slow call?
%

Traces

A trace is the whole journey of one request. It is made of spans: one per step, with a start time and duration. A trace id is passed in an HTTP header (the W3C traceparent standard) so each service attaches its span to the same trace. OpenTelemetry is the vendor-neutral standard for producing logs, metrics and traces.

Quick check
Checkout p99 latency doubled at 14:00. You need to know which downstream service added the time. Which signal is best?

Alerts should fire on user pain (error rate, latency against the SLO) and link to a runbook. Alerts on every CPU spike train people to ignore them.

1 of 4