I assume that you have Prometheus running as described in part 1 of the series.
Grafana is a tool to create rich dashboards from your metrics.
Grafana can ingest from many different data sources, including Prometheus.
Grafana can work without any configuration files. However, we want to configure Prometheus as a data source, so we create
This configuration file will tell Grafana about Prometheus. You could omit this and add the configuration via the Grafana UI.
Add the following to
datasources: - name: Prometheus access: proxy type: prometheus url: http://prometheus:9090 isDefault: true
Next, add the following to
docker-compose.yml to add Grafana:
grafana: image: grafana/grafana:7.5.7 ports: - 3000:3000 restart: unless-stopped volumes: - ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources - grafana-data:/var/lib/grafana
The first volume points to our data source configuration. The second volume is used to save dashboards etc. We need to add the second volume to the
volumes section in
volumes: prometheus-data: grafana-data:
Start Prometheus and Grafana:
docker-compose up -d
http://localhost:3000 in your browser. Use user admin with password admin for the first login.
http://localhost:3000/dashboard/new to add a new dashboard (or use the plus sign in the navigation bar).
In the dropdown which says
-- Grafana -- select
Prometheus. You can select Prometheus here because we added the configuration earlier.
Now we need Grafana to tell what to graph. Add the following PromQL statement to the input field
This will show you how often Prometheus endpoints were called. To learn more about PromQL, see the official documentation.
Apply to save and go back to the dashboard. Finally, click on the dashboard save button in the upper right corner.
Great! Next time I will show you how to add AlertManager to the stack.