Docker integration for Grafana Cloud
Docker is a popular open-source platform that enables developers to create, deploy, and run applications in a virtualized environment called a container. It allows developers to package an application with all its dependencies, libraries, and other components required to run it, into a single container image. The Docker integration collects metrics and logs from a Docker instance and provides useful pre-built dashboards to monitor them.
This integration includes 2 pre-built dashboards to help monitor and visualize Docker metrics and logs.
Before you begin
This integration uses Grafana Alloy Docker service discovery feature to identify and collect logs. To do this, it must have access to docker daemon. To give this access, add the “alloy” user to “docker” group with the following command:
sudo usermod -a -G docker alloyElevated privileges are required to run cAdvisor in Grafana Alloy in standalone mode, See cAdvisor documentation. After installing Grafana Alloy, you must give it elevated permissions. Follow the instructions below:
Open the systemctl unit file to change the user running Grafana Alloy process:
sudo systemctl edit --full alloy.serviceChange User=alloy to User=root and save the file.
Reload systemctl changes using:
sudo systemctl daemon-reloadThen restart Grafana Alloy:
sudo systemctl restart alloy.serviceIn order to successfully collect logs and test the integration connection, at least one container should be running in the docker engine.
Install Docker integration for Grafana Cloud
- In your Grafana Cloud stack, click Connections in the left-hand menu.
- Find Docker and click its tile to open the integration.
- Review the prerequisites in the Configuration Details tab and set up Grafana Alloy to send Docker metrics and logs to your Grafana Cloud instance.
- Click Install to add this integration’s pre-built dashboards to your Grafana Cloud instance, and you can start monitoring your Docker setup.
Configuration snippets for Grafana Alloy
Simple mode
These snippets are configured to scrape a single Docker engine running locally with default ports.
Manually copy and append the following snippets into your Grafana Alloy configuration file.
Integrations snippets
prometheus.exporter.cadvisor "integrations_cadvisor" {
docker_only = true
}
discovery.relabel "integrations_cadvisor" {
targets = prometheus.exporter.cadvisor.integrations_cadvisor.targets
rule {
target_label = "job"
replacement = "integrations/docker"
}
rule {
target_label = "instance"
replacement = constants.hostname
}
}
prometheus.scrape "integrations_cadvisor" {
targets = discovery.relabel.integrations_cadvisor.output
forward_to = [prometheus.remote_write.metrics_service.receiver]
}Logs snippets
linux
Advanced mode
To instruct Grafana Alloy to scrape your docker engine, go though the subsequent instructions.
The snippets provide examples to guide you through the configuration process.
First, manually copy and append the following snippets into your Grafana Alloy configuration file.
Then follow the instructions below to modify the necessary variables.
Advanced integrations snippets
prometheus.exporter.cadvisor "integrations_cadvisor" {
docker_only = true
}
discovery.relabel "integrations_cadvisor" {
targets = prometheus.exporter.cadvisor.integrations_cadvisor.targets
rule {
target_label = "job"
replacement = "integrations/docker"
}
rule {
target_label = "instance"
replacement = constants.hostname
}
}
prometheus.scrape "integrations_cadvisor" {
targets = discovery.relabel.integrations_cadvisor.output
forward_to = [prometheus.remote_write.metrics_service.receiver]
}Add a pair of prometheus.exporter.cadvisor and discovery.relabel to your Grafana Alloy configuration to monitor a docker daemon.
For ease of use, the provided snippets sets the instance label to the hostname using the constants.hostname Agent Flow constant variable.
If you want to monitor more than one daemon running within the same host, set a different value for each to avoid instance label conflicts.
You will also need to set the docker_host and containerd_host properties within prometheus.exporter.cadvisor for each daemon.
There is an array of options available within this component, like setting up tls connection, specific cgroup collection, amongst others.
Refer to prometheus.exporter.cadvisor in Grafana Alloy reference documentation for a complete description of the configuration options.
Finally, reference each discovery.relabel component within the targets property of the prometheus.scrape component.
Advanced logs snippets
linux
Add a group of discovery.docker, discovery.relabel and loki.source.docker to your Grafana Alloy configuration to monitor a docker daemon.
For ease of use, the provided snippets sets the instance label to the hostname using the constants.hostname Agent Flow constant variable.
If you want to monitor more than one daemon running within the same host, set a different value for each to avoid instance label conflicts.
You will also need to set the host property within discovery.docker and loki.source.docker for each daemon.
Make sure that for each docker daemon you are monitoring the instance label is set to the same value within the discovery.relabel components collecting cadvisor metrics and the daemon logs.
Dashboards
The Docker integration installs the following dashboards in your Grafana Cloud instance to help monitor your system.
- Docker logs
- Docker overview
Overview & Compute

Logs

Metrics
The most important metrics provided by the Docker integration, which are used on the pre-built dashboards, are as follows:
- container_cpu_usage_seconds_total
- container_fs_reads_total
- container_fs_usage_bytes
- container_fs_writes_total
- container_last_seen
- container_memory_usage_bytes
- container_network_receive_bytes_total
- container_network_receive_errors_total
- container_network_receive_packets_dropped_total
- container_network_transmit_bytes_total
- container_network_transmit_errors_total
- container_network_transmit_packets_dropped_total
- container_spec_memory_reservation_limit_bytes
- machine_memory_bytes
- machine_scrape_error
- up
Changelog
Cost
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.



