(01)Run with Docker
Linux
1docker run -d --name grafana -p 3000:3000 grafana/grafana2# UI: http://localhost:3000 (admin/admin)Visualization and dashboard platform for metrics, logs, and traces
What is this?
Grafana turns server metrics into charts and dashboards so you can see what's happening at a glance.
Where to create or edit the main configuration — paths below match the setup steps.
/etc/grafana/grafana.iniLocation: Grafana server
Server URL, auth, and data sources path
Step 01
1docker run -d --name grafana -p 3000:3000 grafana/grafana2# UI: http://localhost:3000 (admin/admin)1sudo apt-get install -y software-properties-common2sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"3sudo apt-get update && sudo apt-get install grafana4sudo systemctl enable grafana-serverStep 02
1# Web UI: http://localhost:30002# 1. Configuration → Data Sources → Prometheus → URL: http://prometheus:90903# 2. Dashboards → Import → ID 1860 (Node Exporter)4# 3. Alerting → Contact points → Email/Slack1# datasources.yml:2cat > provisioning/datasources/ds.yml << 'EOF'3apiVersion: 14datasources:5 - name: Prometheus6 type: prometheus7 url: http://prometheus:90908 isDefault: true9EOF10# Mount to /etc/grafana/provisioning/datasources/Step 03
1curl http://localhost:3000/api/healthStep 04
1# In Grafana UI: Configuration → Data Sources → Add Prometheus2# URL: http://prometheus:9090 (Docker network) or http://localhost:9090Step 05
1curl http://localhost:9090/-/healthy2sudo journalctl -u grafana-server -n 303# Settings → Data sources → Test connection in UI2 YAML templates for Grafana. Copy and deploy after setup.
2 ready-to-copy templates. 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