How to Set Up Grafana and Prometheus on Raspberry Pi for System Monitoring
Grafana and Prometheus together form one of the most popular open-source monitoring stacks available. Prometheus collects and stores time-series metrics, while Grafana provides beautiful, customizable dashboards to visualize that data. Paired with Node Exporter for system metrics, you get a complete monitoring solution running on your Raspberry Pi.
What Are These Tools?
- Prometheus is a time-series database that scrapes metrics from configured endpoints at regular intervals and stores them for querying.
- Grafana is a visualization platform that connects to data sources like Prometheus and displays metrics in rich, interactive dashboards.
- Node Exporter is a Prometheus exporter that exposes hardware and OS-level metrics such as CPU usage, memory, disk I/O, and network statistics.
Prerequisites
- A Raspberry Pi (3B+ or newer) running Raspberry Pi OS
- Docker and Docker Compose installed
- A static IP address on your Pi
If you need Docker, follow our Docker installation guide.
Creating the Project Structure
Start by creating a directory for the monitoring stack:
mkdir ~/monitoring && cd ~/monitoring
Prometheus Configuration
Create the Prometheus configuration file first:
nano prometheus.yml
Paste the following configuration:
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["prometheus:9090"]
- job_name: "node-exporter"
static_configs:
- targets: ["node-exporter:9100"]
This tells Prometheus to scrape itself and the Node Exporter service every 15 seconds. The hostnames prometheus and node-exporter work because Docker Compose creates a shared network where services can reach each other by name.
Docker Compose Configuration
Now create the docker-compose.yml file:
nano docker-compose.yml
Paste this configuration:
version: "3"
services:
prometheus:
image: prom/prometheus
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus_data:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.retention.time=30d"
restart: unless-stopped
grafana:
image: grafana/grafana
container_name: grafana
ports:
- "3000:3000"
volumes:
- grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
restart: unless-stopped
node-exporter:
image: prom/node-exporter
container_name: node-exporter
ports:
- "9100:9100"
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- "--path.procfs=/host/proc"
- "--path.sysfs=/host/sys"
- "--path.rootfs=/rootfs"
- "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)"
restart: unless-stopped
volumes:
prometheus_data:
grafana_data:
Starting the Stack
Launch all three services:
docker-compose up -d
Verify everything is running:
docker-compose ps
You should see all three containers in a running state. Prometheus will be available at http://<your-pi-ip>:9090 and Grafana at http://<your-pi-ip>:3000.
Verifying Prometheus Targets
Open Prometheus at http://<your-pi-ip>:9090 and navigate to Status, then Targets. You should see both the prometheus and node-exporter targets listed with a state of UP. If a target shows as DOWN, check that the corresponding container is running with docker logs <container-name>.
Connecting Grafana to Prometheus
Open Grafana at http://<your-pi-ip>:3000 and log in with the default credentials (username: admin, password: admin). You will be prompted to change the password on first login.
To add Prometheus as a data source:
- Click the gear icon in the left sidebar and select Data Sources
- Click Add data source and choose Prometheus
- Set the URL to
http://prometheus:9090 - Click Save & Test at the bottom of the page
You should see a green banner confirming the data source is working. The URL uses the Docker service name prometheus because Grafana and Prometheus share the same Docker network.
Importing a Dashboard
Rather than building dashboards from scratch, you can import community-created dashboards from the Grafana website.
- Click the + icon in the left sidebar and select Import
- Enter dashboard ID 1860 (this is the popular "Node Exporter Full" dashboard)
- Click Load
- Select your Prometheus data source from the dropdown
- Click Import
You will now see a comprehensive dashboard showing CPU usage, memory, disk space, network traffic, and many more system metrics from your Raspberry Pi.
Updating the Stack
To update all services to their latest images:
cd ~/monitoring
docker-compose pull
docker-compose down
docker-compose up -d
Your data is persisted in Docker volumes, so updates will not affect your stored metrics or dashboards.
Troubleshooting
- Grafana shows "No Data": Make sure the Prometheus data source URL is
http://prometheus:9090(notlocalhost). Check that Prometheus targets are UP. - Node Exporter target is DOWN: Run
docker logs node-exporterto check for errors. Ensure the container has read access to/procand/sys. - High disk usage over time: Prometheus stores 30 days of data by default (configured via
--storage.tsdb.retention.time). Reduce this value if disk space is limited. - Grafana not accessible: Confirm port 3000 is not in use by another service. Check with
sudo lsof -i :3000. - ARM compatibility issues: The images used (
prom/prometheus,grafana/grafana,prom/node-exporter) all provide ARM-compatible builds that work on Raspberry Pi.
Conclusion
With Grafana, Prometheus, and Node Exporter running on your Raspberry Pi, you have a professional-grade monitoring stack that gives you deep visibility into your system's health. The community dashboard ecosystem means you can get started quickly, and Grafana's flexibility lets you build custom dashboards tailored to your exact needs.