>_ IzzyLab

Hands-on task

This task is step 11 of the course “Monitoring and metrics”

SLI: share of 2xx

medium~7 min

In /root/access.log there are lines of the form METHOD PATH CODE. Compute the share of successful responses (2xx) as a percentage (whole number) among all requests and write it to /root/sli.txt.

What you'll practise:
  • sli
  • awk
  • percentage share
  • code range
  • integer division

Topic breakdown

An availability SLI is almost always computed as the share of successful responses out of the total number of requests — this metric is then compared against a target SLO. Success here is defined by the 2xx range (200-299), not a single code, so for selection it's enough to check the first digit of the third field. The gotcha is division precision: it's better to compute the share in awk, where division is floating-point, rather than in integer bash arithmetic, and only convert to a whole percentage at the very end.

What's checked

  1. share of 2xx is correct

What it looks like