Stand up Prometheus locally with Docker, point it at targets with a scrape config, and explore the metrics it collects — the foundation of the whole monitoring stack.
Why: Prometheus and Grafana are a team. Prometheus is a time-series database that PULLS metrics by scraping HTTP endpoints on a schedule, stores them, and evaluates alert rules. Grafana reads from Prometheus to draw dashboards. You scrape targets, query with PromQL, alert on rules, and visualize in Grafana — that is the whole course.
targets (/metrics) ──scraped by──▶ Prometheus ──queried by──▶ Grafana
app, node_exporter (pull, every 15s) stores + alerts dashboards
│
▼
Alertmanager ──▶ Slack / emailWhy: the easiest way to run Prometheus and Grafana together is Docker Compose — one file, one command, no installs. This brings up Prometheus on :9090 and Grafana on :3000, with Prometheus reading the config file you write next. Note: the Docker course covers Compose if it is new.
# docker-compose.yml
services:
prometheus:
image: prom/prometheus:latest
ports: ["9090:9090"]
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
grafana:
image: grafana/grafana:latest
ports: ["3000:3000"]Why: prometheus.yml tells Prometheus what to scrape and how often. global sets the default scrape interval; each job under scrape_configs is a set of targets sharing a name. Start by scraping Prometheus itself — it exposes its own metrics at /metrics on :9090.
# prometheus.yml
global:
scrape_interval: 15s # how often to pull metrics
scrape_configs:
- job_name: prometheus # Prometheus scraping itself
static_configs:
- targets: ["localhost:9090"]Why: bring the stack up, then confirm Prometheus is scraping. The Targets page (Status → Targets in the UI, or the API) shows each target as UP or DOWN — your first check that scraping works. A DOWN target with an error message is the most common early problem.
Start Prometheus + Grafana
docker compose up -dPrometheus UI: http://localhost:9090 Check scrape targets are UP:
curl -s http://localhost:9090/api/v1/targets | grep -o '"health":"[a-z]*"'Why: Prometheus has a built-in query UI at /graph (the "expression browser"). Type a metric name and run it to see current values, or switch to the Graph tab for a time series. This is where you prototype queries before putting them in dashboards or alerts. Try these against the Prometheus job you just scraped.
# Total HTTP requests Prometheus has handled
prometheus_http_requests_total
# How long has Prometheus been up? (seconds)
time() - process_start_time_seconds
# Is the target up? (1 = up, 0 = down)
up