Prometheus/Grafana practical setup — Cheat Sheet — Practical Guide (Nov 21, 2025)
body { font-family: Arial, sans-serif; line-height: 1.6; max-width: 800px; margin: 1em auto; padding: 0 1em; }
h2 { border-bottom: 2px solid #333; padding-bottom: 0.3em; }
h3 { margin-top: 1.5em; }
pre { background: #f4f4f4; padding: 1em; overflow-x: auto; border-radius: 4px; }
code { font-family: Consolas, monospace; }
p.audience { font-weight: bold; font-style: italic; margin-bottom: 1em; }
p.social { margin-top: 3em; font-size: 0.9em; color: #555; }
ul { margin-left: 1.3em; }
Prometheus/Grafana practical setup — Cheat Sheet
Level: Intermediate
Updated for Prometheus 2.42.x and Grafana 10.x (LTS range) as of November 21, 2025.
Prerequisites
Before starting your monitoring stack setup with Prometheus and Grafana, ensure you have:
- Basic Linux command-line knowledge: Installation and config editing.
- A host or VM/server: Running a recent Linux distribution (Ubuntu 22.04+, CentOS 8+, or equivalent).
- Network accessibility: Ability to open ports (9090 for Prometheus, 3000 for Grafana by default).
- Docker (optional): Useful if you prefer containerised installs.
- Root or sudo access: To install and configure services.
Versions matter: use Prometheus 2.40+ to get stable support for PromQL instant vectors enhancements and Grafana 10.x for the latest dashboard features and stable unified alerting support.
Hands-on steps
1. Installing Prometheus
The most straightforward approach is to use the official Prometheus binary distribution (recommended for simplicity and control). Alternatively, Docker images maintain parity but may differ slightly in permission setup.
# Download Prometheus 2.42.x (replace with latest stable patch)
wget https://github.com/prometheus/prometheus/releases/download/v2.42.0/prometheus-2.42.0.linux-amd64.tar.gz
tar xvf prometheus-2.42.0.linux-amd64.tar.gz
cd prometheus-2.42.0.linux-amd64
# Optionally, move binaries to /usr/local/bin for system-wide use
sudo cp prometheus promtool /usr/local/bin/
# Copy consoles and console_libraries for web UI rendering
sudo cp -r consoles console_libraries /etc/prometheus/
2. Prometheus configuration (prometheus.yml)
Create a minimal scrape config to monitor itself and your targets; more complex service discovery or file_sd configs can be added later.
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
# Example: monitoring a node exporter on the same host
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100']
3. Running Prometheus
Run Prometheus by specifying config location and storage path.
./prometheus
--config.file=/etc/prometheus/prometheus.yml
--storage.tsdb.path=/var/lib/prometheus/
--web.listen-address=:9090
Consider creating a systemd service for production to manage Prometheus lifecycle properly.
4. Installing Grafana
Grafana 10.x can be installed via official repositories or Docker. For bare-metal, the official docs guide adding the APT/YUM repo.
# For Ubuntu/Debian based systems
sudo apt-get install -y apt-transport-https software-properties-common wget
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
sudo apt-get update
sudo apt-get install grafana
# Start and enable service
sudo systemctl enable --now grafana-server
5. Configuring Grafana to use Prometheus as a data source
- Open
http://<your-host>:3000(default login: admin/admin) - Go to Configuration > Data Sources > Add data source
- Select Prometheus and set URL to
http://localhost:9090(adjust if remote) - Save & Test to verify connection
6. Import Dashboard
Grafana’s Dashboard Library has many community and official dashboards. For node_exporter metrics, use dashboard ID 1860 or similar.
Common pitfalls
- Firewall/Network blocks: Prometheus and Grafana must be able to reach each other and scrape targets. Check ports 9090, 3000, and any exporter ports.
- Permissions issues: Prometheus needs write access to its TSDB directory; running as root is discouraged.
- Config syntax errors: YAML is whitespace-sensitive. Validate config with
promtool check config prometheus.yml. - Scraping wrong targets: Confirm exporters are running and reachable, e.g.
curl localhost:9100/metrics. - Data retention and disk space: The default Prometheus data retention can fill disks quickly in large environments. Use
--storage.tsdb.retention.timeto tune. - Dashboard time ranges: Grafana defaults to 6 hours; too narrow time ranges can be misleading on sparse metrics.
Validation
- Check Prometheus: Visit
http://localhost:9090/targetsand ensure all jobs have “UP” status. - Query basics: Run a simple query like
upin Prometheus expression browser to confirm scrape health. - Test Grafana dashboards: Confirm metric panels graph expected data without errors.
- Log review: Check Prometheus and Grafana logs for errors/warnings during startup and scraping.
Checklist / TL;DR
- ✔ Download and install Prometheus 2.42.x (or latest stable).
- ✔ Write minimal
prometheus.ymlwith at least Prometheus and node_exporter jobs. - ✔ Run Prometheus with proper paths and service management.
- ✔ Install Grafana 10.x from official repos or Docker.
- ✔ Add Prometheus as a Grafana data source at
http://localhost:9090. - ✔ Import community dashboards or create your own.
- ✔ Validate targets via Prometheus UI and metric queries.
- ✔ Monitor firewall and permission issues early.
When to choose Prometheus + Grafana versus alternatives
Choose Prometheus + Grafana if:
- You require a mature, widely supported open-source monitoring and alerting stack.
- You want a powerful, flexible query language (PromQL) with rich visualisation capabilities.
- You prefer self-hosted control over collected data and custom monitoring.
Consider alternative solutions if:
- You want a fully managed solution with less operational overhead (e.g., Datadog, New Relic).
- You need long-term storage and federated monitoring at massive scale; tools like Thanos or Cortex extend Prometheus for those.
- You require more advanced AI-based anomaly detection features or automated root cause analysis (still evolving with Prometheus ecosystem).