The OpenTelemetry Collector provides an integration with Docker stats to ingest metrics about the host machine and the docker daemon’s running containers. Alternatively, you can use the Prometheus receiver to scrape Prometheus metrics from Docker. The Collector fetches metrics from the configured path for either receiver. From there the metrics are processed and exported to Cloud Observability.
The Docker stats receiver is supported only on Linux.
To complete the integration, you will:
The optional Docker Post-installation steps for Linux have been completed.
For the Manage Docker as a non-root user option, you need to assign group ownership (i.e chmod u+x /var/run/docker.sock
) to the Docker socket where the metrics will be scraped.
You’ve configured the Collector to export metric data to Cloud Observability.
Configure Docker’s daemon to report metrics to the Collector:
/etc/docker/daemon.json
that exposes metrics at an address, using the key, metrics-addr
, and a proper IP address:
1
“metrics-addr”: “127.0.0.1:9100”
experimental
:
1
“experimental”: true
Configure remote access for the daemon.
systemd
:
1
sudo systemctl restart docker.service
Visit the Docker docs for more information about configuring the Docker daemon and configuring Docker to use Prometheus.
You can configure the receiver to scrape metrics from either Docker stats or from Prometheus.
In the Collector yaml configuration file, add Docker stats as a receiver and set the endpoint:
1
2
3
4
receivers:
docker_stats:
endpoint: http://localhost:9100
The OpenTelemetry repo provides additional details about Docker stats configuration.
In the Collector configuration file, configure the Prometheus receiver to use the Docker Prometheus endpoint as a scrape target.
1
2
3
4
5
6
7
receivers:
prometheus/docker:
config:
scrape_configs:
- job_name: docker-otel-eg
static_configs:
- targets: [“${IP_ADDRESS}:2375”]
The OpenTelemetry repo provides additional details about Prometheus receiver configuration.
Details about full configuration of the Prometheus scrape configuration can be found here.
Once the Docker stats receiver is configured, enable it by adding it to one or more pipelines as described in the Collector configuration documentation.
You can validate that metrics are reporting to Cloud Observability on the Metrics details page in Settings.
In Cloud Observability, click Settings > Metric details.
Search for Docker stats metric names.
If needed, click on the metric to edit the description and how the units are displayed in Cloud Observability.
Use the Cloud Observability Terraform Provider to create a dashboard for the metrics.
For a more complete example that’s ready to run, see the Docker stats integration in Cloud Observability OpenTelemetry Examples.
Updated Dec 1, 2022