Linux Labs

SRE practices: SLOs, incidents, redundancy / Stage 1 of 8

SLI: the share of good requests

Not running Starting usually ~20 s
Leave the lesson

Step 1 of 6 · on a machine · 4 min

All green from the outside

What you will learn

  • Count availability from an nginx log — the share of good answers among all, with 5xx bad and 4xx not.
  • Select the log lines of a time window by the request's unix time.
  • Find the p95 answer time and explain why the mean cannot replace it.

Support forwards complaints: some of the shop's customers cannot open their orders, and the cart takes seconds to load. You check the site the usual way — the home page opens at once. Compare that with what nginx wrote to its log.

Exercise · look

Check the site and its log

Request the home page, look at the last three lines of access.log and count how many answers with each code the log holds.

First, predict

The home page answered 200 in a few thousandths of a second. What will counting the codes in access.log show?

Now start the exercise, run the command and compare your prediction with the output.

Sign in and start The machine is available after signing in
Check yourself 1 question

curl got 200 from the home page, and access.log holds hundreds of 5xx answers. What follows from this?

  • curl sent one request and printed the code of its answer — 200. The 5xx answers in the log belong to other requests.

  • The lines are fresh: the last ones in sudo tail carry today's time, and new ones appear every second.

  • nginx sends no requests of its own: it writes answers to clients into access.log, and the lines carry the clients' addresses and browsers.

The customers' requests got the 5xx, and curl's single request was among the good ones.

Ubuntu 24.04
Loading…