

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Metrics
incomplete
2: Prometheus
incomplete
3: System Metrics
incomplete
4: Metrics Exporters
incomplete
5: What to Measure
incomplete
6: Visualizing Metrics
incomplete
7: Service Metrics
incomplete
8: Custom Metrics
incomplete
9: Custom Visualizations
incomplete
10: Status Code Bars
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Think of Prometheus as a database for metrics. But a database is only as useful as the data it contains. So where does Prometheus get its data?
Prometheus is pull-based. It scrapes data from sources, then stores that data in its database. This contrasts with push-based systems, where data sources send data directly.
Getting data into Prometheus requires two things:
Add Node Exporter so Prometheus can scrape host-level metrics.
services:
prometheus:
image: prom/prometheus:latest
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
node-exporter:
image: prom/node-exporter:latest
ports:
- "9100:9100"
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ["localhost:9090"]
- job_name: node_exporter
static_configs:
- targets: ["node-exporter:9100"]
docker compose up
Available Memory (in bytes):
node_memory_MemAvailable_bytes
Available Disk Space (in bytes):
node_filesystem_avail_bytes
Prometheus also lets you run functions over stored data like sums and averages. For example, average CPU Usage for the last 5 minutes (percentage):
1 - avg(rate(node_cpu_seconds_total{mode="idle"}[5m]))
Aside from debugging, it's not normal to query Prometheus directly. Another tool like Grafana will typically run these queries for us and visualize the results.
Run and submit the CLI tests from the root of the Linko repo.