Linux Labs

Observability: metrics, alerts, logs / Stage 2 of 9 · step 5 of 6

The app's metrics are not in Prometheus

medium ~20 min
Not running Starting usually ~20 s
Report a problem

Situation

This machine runs a shop: the lab-app application behind nginx, the site is http://shop.lab.test/. The office Prometheus runs here too: every 5 seconds it scrapes its own metrics (the prometheus job) and the machine's (the node job).

The application serves its metrics in the Prometheus format. The web team wants to see them in Prometheus with the label team="web" — its graphs and queries are built on that label. Yesterday a colleague took this on and wrote before leaving: "Added the job, reloaded Prometheus." Yet promtool query instant http://localhost:9090 'up{team="web"}' prints nothing.

There is no browser to the machine: queries — promtool query instant http://localhost:9090 '<query>', the Prometheus API — curl -s localhost:9090/api/v1/… and jq. sudo works without a password.

Task

  1. Prometheus scrapes the metrics of the shop application itself: its target has the label team="web", the target is up, and promtool query instant http://localhost:9090 'labapp_build_info{team="web"}' prints a series.
  2. The shop site works as before: http://shop.lab.test/ answers 200, and http://shop.lab.test/metrics answers 403.
  3. The setting lives in /etc/prometheus/prometheus.yml: promtool check config passes, Prometheus runs with what the file says; the prometheus and node jobs are in place and working.

Constraints

  • The application's metrics are not served to the outside: the shop's nginx closes /metrics on purpose — do not change its configuration.
  • Do not change the lab-app application or its service.

Half a minute after the metrics start flowing, the web team will see its requests by response code like this: promtool query instant http://localhost:9090 'sum by (code) (rate(labapp_http_requests_total{team="web"}[1m]))'

Visible only to you. Saved as you type.

All notes

Lab goals

0 of 3
  • Prometheus scrapes the shop app's metrics — the target with the label team="web" is up, and labapp_* series with this label exist — not checked yet
  • The shop site works as before — / answers 200, and /metrics stays closed to the outside (403) — not checked yet
  • The setting lives in prometheus.yml; promtool check config passes, Prometheus runs with what the file says; the prometheus and node jobs are in place — not checked yet

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…