Step 5 of 6 · lab · 20 min
The app's metrics are not in Prometheus
The web team needs the shop app's metrics in Prometheus with the label team="web". Yesterday a colleague added a job and said it was done — yet there is no data. Finish the job without exposing the metrics to the outside.
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
- Prometheus scrapes the metrics of the shop application itself: its target has the label
team="web", the target isup, andpromtool query instant http://localhost:9090 'labapp_build_info{team="web"}'prints a series. - The shop site works as before:
http://shop.lab.test/answers 200, andhttp://shop.lab.test/metricsanswers 403. - The setting lives in
/etc/prometheus/prometheus.yml:promtool check configpasses, Prometheus runs with what the file says; theprometheusandnodejobs are in place and working.
Constraints
- The application's metrics are not served to the outside: the shop's nginx closes
/metricson purpose — do not change its configuration. - Do not change the
lab-appapplication 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]))'
Lab · on your own
No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.
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 done yet
-
The shop site works as before — / answers 200, and /metrics stays closed to the outside (403) — not done 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 done yet
The machine is starting
Hints
0 of 3Lab 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 done yet
-
The shop site works as before — / answers 200, and /metrics stays closed to the outside (403) — not done 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 done yet
Goals are checked on the machine after every command.