Docker integration for Grafana Cloud
Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.
The Docker integration for Grafana Cloud focuses on showing overall utilization of containers running in Docker, using cAdvisor. The integration installs pre-built dashboards and alerts that are specifically designed to monitor Docker containers. This integration also supports logs monitoring for Docker containers.
Before you begin
The integration collects Docker container metrics through embedded cAdvisor in Grafana agent
This integration uses the Docker service discovery feature of Grafana Agent to identify and collect logs. The agent must have access to the Docker daemon in order to identify and collect logs. To give the agent access to the Docker daemon, you need to add the grafana-agent user to the docker group with the following command:
sudo usermod -a -G docker grafana-agent
Elevated privileges are required to run cAdvisor in Grafana Agent in standalone mode, See cAdvisor documentation. After installing the Grafana agent, you can give the agent elevated permissions by changing the user of the Grafana agent installed service by editing the systemctl unit file with the following commands:
sudo systemctl edit --full grafana-agent.service
User=root and save the file. Then reload systemctl changes:
sudo systemctl daemon-reload
Then restart the Grafana agent:
sudo systemctl restart grafana-agent.service
Install the Docker integration for Grafana Cloud
In your Grafana instance, click Integrations and Connections (lightning bolt icon), then click on the Docker tile to install the integration.
Once the integration is installed, follow the steps on the Configuration Details page to configure Grafana Agent to automatically scrape and send Docker metrics to your Grafana Cloud instance.
Post-install configuration for the Docker integration
This integration supports metrics and logs for Docker containers. In order to see those signals correlated on the same dashboard,
instance labels must match for
logs in the agent configuration file:
The following agent configuration enables the embedded cAdvisor in Grafana agent:
Note: The agent must be configured to collect logs from Docker in the logs config stanza of the agent configuration file using Docker Service Discovery as shown in the example configuration below.
integrations: cadvisor: enabled: true docker_only: true instance: localhost:9090 relabel_configs: - action: replace replacement: integrations/docker target_label: job logs: configs: - name: agent clients: - url: http://loki:3100/api/prom/push positions: filename: /tmp/positions.yaml target_config: sync_period: 10s scrape_configs: - job_name: integrations/docker docker_sd_configs: - host: unix:///var/run/docker.sock refresh_interval: 5s relabel_configs: - action: replace replacement: integrations/docker source_labels: - __meta_docker_container_id target_label: job - source_labels: - __meta_docker_container_name regex: '/(.*)' target_label: container - source_labels: - __meta_docker_container_log_stream target_label: stream
After you have successfully configured the Docker integration, two prebuilt dashboards will be installed in your Grafana instance to help you monitor your Docker metrics and logs.
Docker overview dashboard
This dashboard gives a general overview of the Docker containers based on the metrics exposed by cAdvisor. The dashboard can show aggregated statistics of all containers and it can also show statistics of individual containers based on the selected job, instance, and container
Docker logs dashboard
This dashboard contains statistics of the logs collected by Grafana Agent through Docker Service Discovery. It also contains panels that show errors, warnings, and complete log files in separate views.
Metrics captured by Docker for Grafana Cloud
Refer to the cAdvisor storage documentation for a list of metrics that are automatically written to your Grafana Cloud instance when you connect your Docker instance through this integration.
By connecting your Docker instance to Grafana Cloud you might incur charges. To view information on the number of active series that your Grafana Cloud account uses for metrics included in each Cloud tier, see Active series and dpm usage and Cloud tier pricing.