(01)Run with Docker
Linux
1docker run -d --name prometheus -p 9090:9090 \2 -v ./prometheus.yml:/etc/prometheus/prometheus.yml \3 prom/prometheus4# UI: http://localhost:9090Open-source monitoring and alerting toolkit with time-series database
What is this?
Prometheus collects numbers about your servers — CPU, memory, disk — and stores them over time.
Where to create or edit the main configuration — paths below match the setup steps.
prometheus.ymlLocation: Server or container mount /etc/prometheus/
Scrape targets, rules, and alerting
Step 01
1docker run -d --name prometheus -p 9090:9090 \2 -v ./prometheus.yml:/etc/prometheus/prometheus.yml \3 prom/prometheus4# UI: http://localhost:90901wget https://github.com/prometheus/prometheus/releases/download/v2.54.0/prometheus-2.54.0.linux-amd64.tar.gz2tar xvfz prometheus-*.tar.gz3cd prometheus-*4./prometheus --config.file=prometheus.ymlStep 02
1cat > prometheus.yml << 'EOF'2global:3 scrape_interval: 15s4scrape_configs:5 - job_name: prometheus6 static_configs:7 - targets: ["localhost:9090"]8 - job_name: node9 static_configs:10 - targets: ["localhost:9100"]11 - job_name: kubernetes-pods12 kubernetes_sd_configs:13 - role: pod14EOF15 16docker restart prometheusStep 03
1curl http://localhost:9090/-/healthyStep 04
1# Via UI at http://localhost:9090/graph2# up — target health3# rate(http_requests_total[5m]) — request rate4# node_memory_MemAvailable_bytes — memory1 YAML template for Prometheus. Copy and deploy after setup.
1 ready-to-copy template. Expand one, copy the YAML, then run the deploy commands.
docker-compose.yml
1services:2 prometheus:3 image: prom/prometheus:latest4 ports:5 - "9090:9090"6 volumes:7 - ./prometheus.yml:/etc/prometheus/prometheus.yml8 - prom_data:/prometheus9 10 grafana:11 image: grafana/grafana:latest12 ports:13 - "3000:3000"14 environment:15 GF_SECURITY_ADMIN_PASSWORD: admin16 volumes:17 - grafana_data:/var/lib/grafana18 depends_on:19 - prometheus20 21volumes:22 prom_data:23 grafana_data:prometheus.yml
1global:2 scrape_interval: 15s3 4scrape_configs:5 - job_name: prometheus6 static_configs:7 - targets: ["localhost:9090"]Step 01
1docker compose up -d --build2docker compose ps3docker compose logs -f1docker compose down