Table of Contents
This setup runs Grafana and Prometheus in Docker on one computer. Prometheus collects its own metrics so you can test the whole connection before adding another target. You’ll need a working Docker installation. If you’re new to volumes and networks, use the TipsMake Docker learning path as a reference.
Run Grafana with persistent storage
Create a network for the two containers and a volume for Grafana’s settings and dashboards. Then pull Grafana and start it. The examples assume you can run Docker as your current user. Use your platform’s normal Docker permissions if you receive a permission error.
docker network create monitoring
docker volume create grafana-data
docker pull grafana/grafana
docker run -d --name grafana --network monitoring
-p 127.0.0.1:3000:3000
-v grafana-data:/var/lib/grafana
grafana/grafana
Open http://127.0.0.1:3000 on the Docker host. Sign in with the initial username admin and password admin, then set a new password when prompted. The screenshots show an earlier version of the interface.



Start Prometheus and verify it has a target
Next, create a separate volume for Prometheus data. The image’s bundled example configuration scrapes Prometheus itself. This creates a working target without installing a system exporter.
docker volume create prometheus-data
docker pull prom/prometheus
docker run -d --name prometheus --network monitoring
-p 127.0.0.1:9090:9090
-v prometheus-data:/prometheus
prom/prometheus
On the Docker host, open http://127.0.0.1:9090 and run the query up after the first scrape. A result of 1 means Prometheus reached the target.
Connect Grafana to Prometheus
In Grafana, open Connections > Add new connection, choose Prometheus, and add it as a data source.

Use http://prometheus:9090 as the server URL, then select Save & test. The service name resolves on the shared Docker network. If you enter localhost here, Grafana looks inside its own container. The multi-container networking tutorial explains the difference.

Build your first dashboard panel
Open Dashboards > New > New dashboard.

Select Add visualization and choose your Prometheus data source.


Enter rate(process_cpu_seconds_total[5m]) in the PromQL editor, run the query, and save the panel and dashboard. It shows how many CPU seconds the Prometheus process used per second over the selected period. If it shows no data immediately, test up and give Prometheus time to collect more samples.

Import a dashboard or add host metrics
In the dashboard import screen, enter an ID from the Grafana dashboard catalog and map it to your data source. Community dashboards may rely on metrics from a particular exporter. For host CPU, memory, and filesystem metrics, configure an appropriate exporter and add it as a target using the Prometheus setup guide.

Reader Comments 0
Sign in with email or Google to join the discussion.