Sign inSign up free

1429. Two LogQL Queries for the Dashboard

medium 20 XP ~15 minHands-on lab

A small online shop sends its logs to Loki. Every line has two labels, service and level (info, warn or error), and a body in logfmt, for example:

level=info service=cart msg="POST /items" status=200 duration_ms=14 trace_id=4bf9…
ToolHoldsAddress on this machine
Grafanadashboards and Explore for the three belowhttp://127.0.0.1:3000
Prometheusmetrics and alert ruleshttp://127.0.0.1:9090
Lokilogshttp://127.0.0.1:3100
Tempotraceshttp://127.0.0.1:3200

Open Grafana with the button above the terminal (Explore, data source Loki).

Task

Write two LogQL queries for new dashboard panels:

  1. /home/student/errors.logql: error log lines per second for each service, over the last 5 minutes. One series per service that logged errors, labelled only with service.
  2. /home/student/slow.logql: for each service, how many requests in the last 10 minutes took longer than 1000 ms, using the duration_ms field of its log lines. One series per service that had any, labelled only with service.

Each file holds the query only.

About this machine

Ubuntu 24.04 with no internet access, running the real Prometheus, Loki, Tempo and Grafana (unmodified) and a simulated shop that reports to them. Once the machine is running, Grafana and Prometheus open in a new tab from the buttons above the terminal. The history goes back about an hour. curl, jq and promtool are installed. The grader checks your answer, not the commands you typed. BrokenCluster is not affiliated with, endorsed or sponsored by Grafana Labs or the Prometheus project.

Part of Observability in Practice. Next step: What "for" Does in an Alert

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.