← Back to blog

October 8, 2026 · 17 min read

Observability 101: Logs, Metrics, and Traces Explained

From Mid-Level to Senior · Part 9 of 18

  • #observability
  • #monitoring
  • #devops
  • #senior-engineer
  • #engineering-practices

A message arrives in the team channel: "checkout is slow". No error, no stack trace, just a customer support person who heard it from three customers.

What happens in the next ten minutes says a lot about your system. On some teams, someone opens a dashboard, sees that the p99 of one endpoint tripled twenty minutes ago, clicks through to a slow request, and reads that the time is going into a call to the payment provider. On other teams, someone opens an SSH session, runs grep on a log file, and starts guessing.

Both teams knew something was wrong. Only the first one could find out why without guessing. That's the gap this part is about.

Part 8 ended with a pipeline that can tell you a deploy finished but can't tell you if the system is healthy afterwards. Here we look at the three signals that answer that question (logs, metrics, and traces), what each one is good and bad at, and how to start without buying a platform. The examples use Spring Boot with Prometheus, Loki, and Grafana, because that's the stack I've rolled out, but the ideas are the same with any vendor.

Monitoring and observability

The two words get used as synonyms, and the difference is useful.

Monitoring is checking for problems you already know about. CPU above 90%, disk almost full, health check failing. You predicted the question and built a check for it.

Observability is being able to answer questions you didn't predict, using what the system already emits, without shipping new code to find out. "Why is checkout slow only for customers paying with one specific card brand, only since 14:10?" Nobody wrote a dashboard for that. A system is observable if you can still answer it.

You need both. Monitoring wakes you up. Observability is what lets you go back to sleep.

Three signals, three different questions

Three panels side by side. Metrics: answers 'is something wrong, and how much?', drawn as a line chart with a spike; good at alerts, trends and dashboards; weak at explaining a single request; cheap, with a cost that grows with the number of label combinations. Logs: answers 'what exactly happened in this event?', drawn as lines of structured log text; good at the detail of one event, with any field you want; weak at showing the overall picture; cost grows with volume. Traces: answers 'where did the time go?', drawn as a small waterfall of bars; good at following one request across services; weak at totals and trends, because most systems only keep a sample; cost controlled by sampling. A bar at the bottom shows the usual path during an incident: a metric tells you something is wrong, a trace tells you where, and a log tells you why.

  • Metrics are numbers aggregated over time: requests per second, error ratio, latency percentiles, connections in use. They're cheap to store and fast to query, which makes them the right signal for dashboards and alerts. What they can't do is explain one specific request. A metric tells you 2% of checkouts failed. It doesn't tell you which ones.
  • Logs are records of individual events, with as much detail as you decide to write. They tell you exactly what happened to order 48213. They're bad at the overall picture (nobody reads ten thousand lines to find a trend), and they get expensive fast, because cost follows volume.
  • Traces follow one request through every service and dependency it touches, with the time spent in each step. They answer "where did the time go?", which is the question neither of the others answers well. Most systems keep only a sample of traces, so they're poor at totals.

During an incident, the usual path goes through all three. A metric tells you something is wrong and how bad it is. A trace of one affected request tells you where the problem is. The logs of that step tell you why. If moving from one to the next means copying an ID by hand between three tools with three different time pickers, people won't do it under pressure. Much of the practical work in observability is making those jumps a single click.

Logs you can query

Most applications already log. The problem is that they log for a human reading a terminal:

2026-10-08 14:12:03 INFO  PaymentService - Payment authorized for order 48213 (customer 9917) in 412 ms

That's fine for one instance on your machine. With twelve instances and a few million lines a day, the only thing you can do with that line is a text search. You can't ask "how many authorizations took more than a second, grouped by card brand", because the duration and the brand are buried in a sentence.

A structured log is the same event written as data:

{
  "@timestamp": "2026-10-08T14:12:03.412Z",
  "log.level": "INFO",
  "service.name": "payment-service",
  "message": "payment authorized",
  "traceId": "6b2f9c1e8a4d4f0f9a3c1d2e5b7a9c10",
  "orderId": 48213,
  "cardBrand": "visa",
  "durationMs": 412
}

Now every field is something you can filter and group by. In Spring Boot 3.4 and later this is one property, with no extra library:

logging.structured.format.console=ecs

And in the code, pass the values as fields instead of gluing them into the message:

log.atInfo()
   .setMessage("payment authorized")
   .addKeyValue("orderId", order.id())
   .addKeyValue("cardBrand", card.brand())
   .addKeyValue("durationMs", elapsed.toMillis())
   .log();

A few habits that make logs worth what they cost:

  • Keep the message constant and put the variables in fields. "payment authorized" should be the same string every time, so you can count it.
  • Put a trace ID on every line. It's what lets you pull every line from every service for one request. With Micrometer Tracing on the classpath, Spring Boot adds traceId and spanId to the logging context for you.
  • Use levels honestly. ERROR means someone should look at this. WARN means it worked, but something unexpected happened. INFO is for business events worth counting. If your ERROR stream is full of things nobody acts on, real errors are hiding in it, the same way a flaky test hides a real failure.
  • Log an exception once, at the place where it's handled. The same stack trace printed at four layers makes one failure look like four.
  • Never log secrets or personal data. Tokens, passwords, card numbers, national ID numbers. Logs are copied to more places and kept longer than you think, and far more people can read them than can read the database.
  • Write to stdout and let the platform collect it. The application shouldn't know where its logs end up.

One warning if you use Loki. It indexes labels, not the content of the lines, and it's built for a small number of labels with few values (service, environment, level). Putting orderId or userId in a label creates one stream per value and makes everything slow. Those belong inside the log line, where you filter them at query time.

Metrics: RED for services, USE for resources

The hard part with metrics is choosing which ones matter. Two short checklists cover most of it.

Two panels. Left, RED, for anything that serves requests such as an API or a consumer. Rate: how many requests per second. Errors: how many of them fail. Duration: how long they take, as percentiles p50, p95 and p99, never the average. Example metric: http_server_requests_seconds. Right, USE, for anything that can run out, such as a connection pool, threads, CPU, a queue or a disk. Utilization: how much of it is in use. Saturation: how much work is waiting for it. Errors: failures of the resource itself, like timeouts getting a connection. Example metric: hikaricp_connections_pending. A note at the bottom says that RED tells you users are being affected and USE tells you which resource ran out.

RED is for anything that serves requests, like an API or a message consumer:

  • Rate: how many requests per second.
  • Errors: how many of them fail.
  • Duration: how long they take.

USE is for anything that can run out, like a connection pool, a thread pool, CPU, memory, a queue, or a disk:

  • Utilization: how much of it is in use.
  • Saturation: how much work is waiting for it.
  • Errors: failures of the resource itself.

RED describes what your users are feeling. USE usually tells you which resource is behind it. A classic pair: checkout latency goes up (RED), and at the same moment the database connection pool shows threads waiting for a connection (USE saturation). In Part 7 we talked about slow queries and pool sizing; this is where you see them happening.

With Spring Boot you get a lot of this without writing code. Add Actuator and the Prometheus registry, and every HTTP endpoint is timed as http.server.requests, with the JVM, HikariCP, and Tomcat thread pool metrics alongside. The error ratio of a service is then one query:

sum(rate(http_server_requests_seconds_count{status=~"5.."}[5m]))
  /
sum(rate(http_server_requests_seconds_count[5m]))

Three things about metrics that people usually learn the hard way:

Averages hide the problem. If 95 requests take 100 ms and 5 take 8 seconds, the average is about half a second and looks acceptable. Five percent of your users would disagree. Look at percentiles (p50, p95, p99), and to get them across several instances you need histograms. In Spring Boot that's a property:

management.metrics.distribution.percentiles-histogram.http.server.requests=true
histogram_quantile(0.99,
  sum by (le, uri) (rate(http_server_requests_seconds_bucket[5m])))

Cardinality is where the bill comes from. Every unique combination of label values is a separate time series. Method, route, and status are a few hundred series. Add a userId label and you have millions, and a Prometheus that falls over. Keep labels to things with a small, known set of values. Use the route template (/orders/{id}) and never the raw path. Anything with high cardinality goes into logs and traces.

Technical metrics aren't enough. Add a few counters for what the business cares about: orders created, payments declined, quotes issued. A service can be perfectly healthy by every RED metric while selling nothing because a partner integration is quietly returning empty results. A line that normally goes up and has been flat for an hour is often the earliest signal you'll get.

Reading a trace

A trace is the story of one request. It's made of spans, where each span is one operation with a start time, a duration, and a parent: an HTTP call received, a query, a call to another service. Services pass the trace ID to each other in a request header (the W3C traceparent header is the standard), which is how spans from different services end up in the same trace.

Back to the slow checkout. Here's the trace of one request that took 1.84 seconds:

A trace waterfall for POST /checkout with a total of 1,840 milliseconds. Each row is a span drawn as a horizontal bar on a time axis. The root span in order-service covers the whole duration. Under it: validate cart, 20 ms; a call to inventory-service to reserve stock, 60 ms; a call to payment-service to authorize, 1,650 ms; and at the end an INSERT into the orders table, 45 ms. Inside the payment-service span there are three children: a fraud check of 90 ms, a first POST to the acquirer API that runs for 1,000 ms and ends in a timeout, highlighted in amber, and a second attempt that succeeds in 510 ms. A note says that 1.5 of the 1.84 seconds was spent waiting for one external call, and that the response was a 200, so no error was logged anywhere.

Read it from top to bottom:

  1. The root span is POST /checkout in order-service, 1,840 ms. That's what the customer felt.
  2. Validating the cart took 20 ms and reserving stock in inventory-service took 60 ms. Neither is the problem.
  3. The call to payment-service took 1,650 ms. So almost all the time is in there.
  4. Inside it, the fraud check is 90 ms. Then there are two calls to the acquirer's API: the first one runs for exactly 1,000 ms and ends in a timeout, and the second one succeeds in 510 ms.
  5. The INSERT at the end is 45 ms.

In about thirty seconds you know things that would have taken an hour of guessing. The database is fine. Our own code is fine. The time is going into an external provider, and the client has a one second timeout with a retry, so every slow call costs the customer at least a full second before the second attempt starts. And since the request ended with a 200, no error was logged anywhere. The logs alone would never have shown it.

That's also why a trace often shows you design problems you weren't looking for: the same query executed forty times in a loop, three calls in sequence that could run in parallel, a retry nobody remembered configuring.

A few practical notes:

  • Let the instrumentation do the work. With Micrometer Tracing or the OpenTelemetry Java agent, incoming requests, HTTP clients, JDBC, and messaging are traced without you writing spans. Add manual spans only around the business steps that matter.
  • Propagation is where traces break. An HTTP client built by hand that doesn't forward the header, a message published without the context, a task handed to a thread pool. When a trace stops in the middle, look there first.
  • You won't keep everything. Spring Boot samples 10% of requests by default (management.tracing.sampling.probability). That's fine to begin with. The limitation of deciding at the start of a request is that you can't know yet if it will be interesting. Tail sampling, usually done in an OpenTelemetry Collector, decides at the end and can keep every error and every slow request. It's worth the extra component once you have real traffic.
  • OpenTelemetry is the standard to bet on. Instrument once, and send the data to whichever backend you choose now or change to later.

SLOs in one paragraph

An SLI (service level indicator) is a measurement of what the user experiences, such as the share of checkout requests that succeed in under 500 ms. An SLO (service level objective) is the target you set for it: 99.9% over 30 days. Whatever is left is your error budget, and 0.1% of 30 days is about 43 minutes of being broken per month. That number is what makes the idea useful. While there's budget left, you ship. When it's burning fast, you slow down and fix reliability, and you have an argument for doing so that isn't just your opinion. It also gives you better alerts: page a person when the budget is burning quickly, and stop paging for a 30 second CPU spike that no user noticed. An SLA is a different thing, the promise in the contract, with consequences if you miss it. Keep your internal SLO stricter than the SLA, so you find out before the customer's lawyer does.

Alerts that deserve to wake someone

The same principle from Part 8 applies here. A pipeline is trusted when red means stop, and an alert is trusted when it means somebody has to do something.

  • Alert on symptoms, investigate with causes. Users seeing errors or slowness is a page. High CPU is a line on a dashboard you look at once you've been paged.
  • Every alert has an action. If the honest response is "wait and see if it goes away", it shouldn't page anyone.
  • Link a runbook, even if it's five lines: what this means, where to look first, who to call.
  • Review the alerts regularly. If one fired ten times last month and nobody did anything, fix it or delete it. A noisy on-call channel teaches people to mute it.

What a rollout taught me

I led the rollout of Grafana, Loki, and Prometheus across our services, and SLA incidents dropped by around 40% afterwards. I'd like to say the tools did that, but installing them is the easy part. What I'd repeat on any team is the less exciting work around them:

  • Standardize before you instrument. The same log format, the same field names, and the same base metrics and labels in every service. One shared dashboard that works for all of them is worth more than twenty handmade ones, and it means a person on call can open a service they've never seen and know where to look.
  • Deliver it in the template. If a new service gets logs, metrics, and a dashboard by default, everybody has them. If each team has to remember to set it up, half of them will.
  • Make the jumps short. From an alert to the dashboard, from a point on a graph to the logs of that minute, from a log line to its trace.
  • Use it when nothing is on fire. A team that only opens the dashboards during incidents is learning the tool at the worst possible moment. Look at them after every deploy.

Incidents go down for a simple reason. Most of them start as something small and visible: a queue growing slowly, a pool getting close to its limit, an error rate going from 0.1% to 0.6%. If somebody sees it at that stage, it gets fixed on a Tuesday afternoon and never becomes an incident.

Where to start

If you have almost nothing today, this order gives the most for the effort:

  1. Structured logs to stdout, with a trace ID, collected somewhere you can search.
  2. RED metrics for every service, plus the JVM and connection pool, on one shared dashboard.
  3. Two or three alerts on symptoms: error ratio and latency on your most important flows.
  4. Tracing, starting with the flows that cross the most services.
  5. One SLO for the one flow the business cares about most.

Buy or build is a fair question. Running Prometheus, Loki, and Grafana yourself is cheap in licences and costs you operating time. A SaaS vendor is the opposite. For a small team, hosted is usually the right first answer. What matters more is the instrumentation, and if that's done with OpenTelemetry and Micrometer, you can change your mind later.

What to try this week

  • Pick one recent incident and ask which signal would have shortened it. That's your first investment.
  • Open your logs and try to answer a question with a query instead of a text search: how many failures per endpoint in the last hour? If you can't, start with structured logging.
  • Check if your latency dashboard shows averages. If it does, switch it to p95 and p99 and see what changes.
  • Follow one request across two services using an ID. If you can't, that's your propagation gap.
  • List the alerts that fired last month and mark the ones nobody acted on.

The short version

  • Monitoring tells you something broke. Observability lets you find out why, including for questions you didn't predict.
  • Metrics say something is wrong, traces say where, logs say why. Make it easy to move between them.
  • Write logs as structured data with a trace ID. Constant message, variables in fields, no secrets.
  • RED for services (rate, errors, duration), USE for resources (utilization, saturation, errors). Percentiles, not averages. Watch label cardinality.
  • A trace shows where the time went. Let auto-instrumentation do most of it, and check propagation when a trace breaks.
  • An SLO turns "is it reliable enough?" into a number, and an error budget tells you when to slow down.
  • Alert on what users feel. Every page needs an action.
  • Standards and defaults matter more than the tool you choose.

Seeing a problem is half of the job. The other half is what you do in the first minutes after the alert fires, with people asking for updates and three theories in the channel. That's Part 10: a calm, repeatable way to debug a production incident.

This is Part 9 of 18 in the series. The Senior Engineer Roadmap maps the whole series, with a short self-assessment and four reading orders.