Overview

OpenTelemetry Docker metrics in a Containers dashboard

To collect container metrics, configure the Docker stats receiver in your Datadog Exporter.

For more information, see the OpenTelemetry project documentation for the Docker stats receiver.

Setup

The Docker stats receiver needs access to the Docker socket. By default, the receiver looks for the Docker socket at unix:///var/run/docker.sock. If this is not the Docker socket path, specify the path in the endpoint configuration line.

Add the following lines to your Collector configuration:

receivers:
  docker_stats:
    endpoint: unix:///var/run/docker.sock # (default)
    metrics:
      container.network.io.usage.rx_packets:
        enabled: true
      container.network.io.usage.tx_packets:
        enabled: true
      container.cpu.usage.system:
        enabled: true
      container.memory.rss:
        enabled: true
      container.blockio.io_serviced_recursive:
        enabled: true
      container.uptime:
        enabled: true
      container.memory.hierarchical_memory_limit:
        enabled: true

Note: If you are using the collector image, you may need to configure additional permissions for the collector to have access to the Docker socket.

The Docker stats receiver needs access to the Docker socket. In Kubernetes, if you are running Docker as a runtime, mount the Docker socket:

Add the following lines to values.yaml:

extraVolumes:
 - name: docker-sock
   hostPath:
     path: /var/run/docker.sock
extraVolumeMounts:
 - name: docker-sock
   mountPath: /var/run/docker.sock

Add the following in the Collector configuration:

receivers:
  docker_stats:
    endpoint: unix:///var/run/docker.sock # default
    metrics:
      container.network.io.usage.rx_packets:
        enabled: true
      container.network.io.usage.tx_packets:
        enabled: true
      container.cpu.usage.system:
        enabled: true
      container.memory.rss:
        enabled: true
      container.blockio.io_serviced_recursive:
        enabled: true
      container.uptime:
        enabled: true
      container.memory.hierarchical_memory_limit:
        enabled: true

Data collected

The Docker Stats receiver generates container metrics for the OpenTelemetry Collector. The Datadog Exporter translates container metrics to their Datadog counterparts for use in the following views:

Note: To correlate trace and container metrics, configure Universal Service Monitoring attributes for each service, and set the following resource attributes for each service:

  • k8s.container.name
  • k8s.pod.name
  • container.name
  • container.id

Learn more about mapping between OpenTelemetry and Datadog semantic conventions for resource attributes.

The following table shows what Datadog container metric names are associated with corresponding OpenTelemetry container metric names

Datadog Metric NameOTel Docker Stats Metric NameMetric Description
container.cpu.usagecontainer.cpu.usage.totalThe container total CPU Usage
container.cpu.usercontainer.cpu.usage.usermodeThe container userspace CPU usage
container.cpu.systemcontainer.cpu.usage.systemThe container system CPU usage
container.cpu.throttledcontainer.cpu. throttling_data.throttled_timeThe total cpu throttled time
container.cpu.throttled.periodscontainer.cpu. throttling_data.throttled_periodsThe number of periods during which the container was throttled
container.memory.usagecontainer.memory.usage.totalThe container total memory usage
container.memory.kernelcontainer.memory.active_anonThe container kernel memory usage
container.memory.limitcontainer.memory. hierarchical_memory_limitThe container memory limit
container.memory.soft_limitcontainer.memory.usage.limitThe container memory soft limit
container.memory.cachecontainer.memory.total_cacheThe container cache usage
container.memory.swapcontainer.memory.total_swapThe container swap usage
container.io.writecontainer.blockio. io_service_bytes_recursive
Attribute Filter operation=write
The number of bytes written to disks by this container
container.io.readcontainer.blockio. io_service_bytes_recursive
Attribute Filter operation=read
The number of bytes read from disks by this container
container.io.write.operationscontainer.blockio. io_serviced_recursive
Attribute Filter operation=write
The number of write operations done by this container
container.io.read.operationscontainer.blockio. io_serviced_recursive
Attribute Filter operation=read
The number of read operations done by this container
container.net.sentcontainer.network.io. usage.tx_bytesThe number of network bytes sent (per interface)
container.net.sent.packetscontainer.network.io. usage.tx_packetsThe number of network packets sent (per interface)
container.net.rcvdcontainer.network.io. usage.rx_bytesThe number of network bytes received (per interface)
container.net.rcvd.packetscontainer.network.io. usage.rx_packetsThe number of network packets received (per interface)

See OpenTelemetry Metrics Mapping for more information.

Full example configuration

For a full working example configuration with the Datadog exporter, see docker-stats.yaml.

Example logging output

Resource SchemaURL: https://opentelemetry.io/schemas/1.6.1
Resource attributes:
     -> container.runtime: Str(docker)
     -> container.hostname: Str(be51776e036e)
     -> container.id: Str(be51776e036e04461169fce2847d4e77be3d83856b474ad544143afc3d48e9e5)
     -> container.image.name: Str(sha256:9bdff337981de15f8cdf9e73b24af64a03e2e6dd1f156a274a15c1d8db98ab79)
     -> container.name: Str(redis-otel)
ScopeMetrics #0
ScopeMetrics SchemaURL: 
InstrumentationScope otelcol/dockerstatsreceiver 0.89.0-dev
Metric #6
Descriptor:
     -> Name: container.cpu.utilization
     -> Description: Percent of CPU used by the container.
     -> Unit: 1
     -> DataType: Gauge
NumberDataPoints #0
StartTimestamp: 2023-11-20 14:58:17.522765 +0000 UTC
Timestamp: 2023-11-20 14:58:19.550208 +0000 UTC
Value: 0.170933
PREVIEWING: brett0000FF/node-compatibility