Skip to main content

Dockerstats Receiver

Status Available in: contrib Maintainers: @jamesmoessis Source: opentelemetry-collector-contrib

Supported Telemetry

Metrics

Overview

:information_source: Requires Docker API version 1.25+

Configuration

The following settings are optional:
  • endpoint (default = unix:///var/run/docker.sock (Linux) , default = npipe:////./pipe/docker_engine (Windows) ): Address to reach the desired Docker daemon.
  • collection_interval (default = 10s): The interval at which to gather container stats.
  • initial_delay (default = 1s): defines how long this receiver waits before starting.
  • container_labels_to_metric_labels (no default): A map of Docker container label names whose label values to use as the specified metric label key.
  • env_vars_to_metric_labels (no default): A map of Docker container environment variables whose values to use as the specified metric label key.
  • excluded_images (no default, all running containers monitored): A list of strings, regexes, or globs whose referent container image names will not be among the queried containers. !-prefixed negations are possible for all item types to signify that only unmatched container image names should be excluded.
    • Regexes must be placed between / characters: /my?egex/. Negations are to be outside the forward slashes: !/my?egex/ will exclude all containers whose name doesn’t match the compiled regex my?egex.
    • Globs are non-regex items (e.g. /items/) containing any of the following: *[]{}?. Negations are supported: !my*container will exclude all containers whose image name doesn’t match the blob my*container.
  • timeout (default = 5s): The request timeout for any docker daemon query.
  • api_version (default = auto-negotiate): The Docker client API version (must be 1.25+). When not specified, the client automatically negotiates the highest mutually supported API version with the Docker daemon. To pin a specific version, set it as a string, not a float (e.g. "1.44" instead of 1.44). Docker API versions.
  • metrics (defaults at ./documentation.md): Enables/disables individual metrics. See ./documentation.md for full detail.
Example:
receivers:
  docker_stats:
    endpoint: http://example.com/
    collection_interval: 2s
    timeout: 20s
    api_version: "1.25"
    container_labels_to_metric_labels:
      my.container.label: my-metric-label
      my.other.container.label: my-other-metric-label
    env_vars_to_metric_labels:
      MY_ENVIRONMENT_VARIABLE: my-metric-label
      MY_OTHER_ENVIRONMENT_VARIABLE: my-other-metric-label
    excluded_images:
      - undesired-container
      - /.*undesired.*/
      - another-*-container
    metrics:
      container.cpu.usage.percpu:
        enabled: true
      container.network.io.usage.tx_dropped:
        enabled: false
The full list of settings exposed for this receiver are documented in config.go with detailed sample configurations in testdata/config.yaml.

Docker Socket Permissions

Requirements

This receiver requires access to the Docker daemon socket to query container statistics. The Docker socket requires specific permissions:
  • Linux (/var/run/docker.sock): Accessible by root user or members of the docker group
  • Windows (npipe:////./pipe/docker_engine): Requires appropriate named pipe permissions
Since version 0.40.0, official OpenTelemetry Collector images run as a non-root user for security. This creates a permission conflict when accessing the Docker socket.

Permission Solutions

Grant Docker Group Access

On Linux, grant the collector process access to the docker group by adding the host’s docker group ID as a supplementary group to the container process:

getent group docker

# Linux example - Run with docker group (replace 999 with your docker group GID from above)
docker run --group-add 999 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  otel/opentelemetry-collector-contrib:latest
Note: The --group-add flag adds the host’s group ID as a supplementary group to the container process. This works because the mounted socket retains the host’s group ownership. If you have user namespaces enabled in Docker, additional configuration may be required.

Run as Root

If running as root is acceptable for your environment:
# Linux example
docker run -u 0 -v /var/run/docker.sock:/var/run/docker.sock \
  otel/opentelemetry-collector-contrib:latest
Note: Running as root is not recommended for production environments.

Alternative Approaches

For enhanced security, consider:
  • Using a Docker API proxy (e.g. docker-socket-proxy) that restricts access to only required endpoints
  • Running this receiver in an isolated collector instance with elevated privileges that only exports data (does not expose receiver ports like OTLP or Zipkin), forwarding metrics to your main collector via OTLP. This reduces the attack surface and RCE risk on the privileged container.
For more information, see issue #11791.

Deprecations

Transition to cpu utilization metric name aligned with OpenTelemetry specification

The Docker Stats receiver has been emitting the following cpu memory metric:
  • [container.cpu.percent] for the percentage of CPU used by the container,
This is in conflict with the OpenTelemetry specification, which defines [container.cpu.utilization] as the name for this metric. To align the emitted metric names with the OpenTelemetry specification, the following process will be followed to phase out the old metrics:
  • Between v0.79.0 and v0.86.0, the new metric is introduced and the old metric is marked as deprecated. Only the old metric are emitted by default.
  • In v0.88.0, the old metric is disabled and the new one enabled by default.
  • In v0.89.0 and up, the old metric is removed.
To change the enabled state for the specific metrics, use the standard configuration options that are available for all metrics. Here’s an example configuration to disable the old metrics and enable the new metrics:
receivers:
  docker_stats:
    metrics:
      container.cpu.percent:
        enabled: false
      container.cpu.utilization:
        enabled: true

Migrating from ScraperV1 to ScraperV2

Note: These changes are now in effect and ScraperV1 have been removed as of v0.71. There are some breaking changes from ScraperV1 to ScraperV2. The work done for these changes is tracked in #9794.
Breaking ChangeAction
Many metrics are no longer emitted by default.See documentation.md to see which metrics are enabled by default. Enable/disable as desired.
BlockIO metrics names changed. The type of operation is no longer in the metric name suffix, and is now in an attribute. For example container.blockio.io_merged_recursive.read becomes container.blockio.io_merged_recursive with an operation:read attribute.Be aware of the metric name changes and make any adjustments to what your downstream expects from BlockIO metrics.
Memory metrics measured in Bytes are now non-monotonic sums instead of gauges.Most likely there is no action. The aggregation type is different but the values are the same. Be aware of how your downstream handles gauges vs non-monotonic sums.
Config option provide_per_core_cpu_metrics has been removed.Enable the container.cpu.usage.percpu metric as per documentation.md.

Metrics

Metric NameDescriptionUnitTypeAttributes
❌ container.blockio.io_merged_recursiveNumber of bios/requests merged into requests belonging to this cgroup and its descendant cgroups (Only available with cgroups v1).{operations}Counterdevice_major, device_minor, operation
❌ container.blockio.io_queued_recursiveNumber of requests queued up for this cgroup and its descendant cgroups (Only available with cgroups v1).{operations}Counterdevice_major, device_minor, operation
βœ… container.blockio.io_service_bytes_recursiveNumber of bytes transferred to/from the disk by the group and descendant groups.ByCounterdevice_major, device_minor, operation
❌ container.blockio.io_service_time_recursiveTotal amount of time in nanoseconds between request dispatch and request completion for the IOs done by this cgroup and descendant cgroups (Only available with cgroups v1).nsCounterdevice_major, device_minor, operation
❌ container.blockio.io_serviced_recursiveNumber of IOs (bio) issued to the disk by the group and descendant groups (Only available with cgroups v1).{operations}Counterdevice_major, device_minor, operation
❌ container.blockio.io_time_recursiveDisk time allocated to cgroup (and descendant cgroups) per device in milliseconds (Only available with cgroups v1).msCounterdevice_major, device_minor, operation
❌ container.blockio.io_wait_time_recursiveTotal amount of time the IOs for this cgroup (and descendant cgroups) spent waiting in the scheduler queues for service (Only available with cgroups v1).nsCounterdevice_major, device_minor, operation
❌ container.blockio.sectors_recursiveNumber of sectors transferred to/from disk by the group and descendant groups (Only available with cgroups v1).{sectors}Counterdevice_major, device_minor, operation
❌ container.cpu.limitCPU limit set for the container.{cpus}Gauge
❌ container.cpu.logical.countNumber of cores available to the container.{cpus}Gauge
❌ container.cpu.sharesCPU shares set for the container.1Gauge
❌ container.cpu.throttling_data.periodsNumber of periods with throttling active.{periods}Counter
❌ container.cpu.throttling_data.throttled_periodsNumber of periods when the container hits its throttling limit.{periods}Counter
❌ container.cpu.throttling_data.throttled_timeAggregate time the container was throttled.nsCounter
βœ… container.cpu.usage.kernelmodeTime spent by tasks of the cgroup in kernel mode (Linux). Time spent by all container processes in kernel mode (Windows).nsCounter
❌ container.cpu.usage.percpuPer-core CPU usage by the container (Only available with cgroups v1).nsCountercore
❌ container.cpu.usage.systemSystem CPU usage, as reported by docker.nsCounter
βœ… container.cpu.usage.totalTotal CPU time consumed.nsCounter
βœ… container.cpu.usage.usermodeTime spent by tasks of the cgroup in user mode (Linux). Time spent by all container processes in user mode (Windows).nsCounter
βœ… container.cpu.utilizationPercent of CPU used by the container.1Gauge
❌ container.memory.active_anonThe amount of anonymous memory that has been identified as active by the kernel.ByUpDownCounter
❌ container.memory.active_fileCache memory that has been identified as active by the kernel.ByUpDownCounter
❌ container.memory.anonAmount of memory used in anonymous mappings such as brk(), sbrk(), and mmap(MAP_ANONYMOUS) (Only available with cgroups v2).ByUpDownCounter
❌ container.memory.cacheThe amount of memory used by the processes of this control group that can be associated precisely with a block on a block device (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.dirtyBytes that are waiting to get written back to the disk, from this cgroup (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.failsNumber of times the memory limit was hit.{fails}Counter
βœ… container.memory.fileAmount of memory used to cache filesystem data, including tmpfs and shared memory (Only available with cgroups v2).ByUpDownCounter
❌ container.memory.hierarchical_memory_limitThe maximum amount of physical memory that can be used by the processes of this control group (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.hierarchical_memsw_limitThe maximum amount of RAM + swap that can be used by the processes of this control group (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.inactive_anonThe amount of anonymous memory that has been identified as inactive by the kernel.ByUpDownCounter
❌ container.memory.inactive_fileCache memory that has been identified as inactive by the kernel.ByUpDownCounter
❌ container.memory.mapped_fileIndicates the amount of memory mapped by the processes in the control group (Only available with cgroups v1).ByUpDownCounter
βœ… container.memory.percentPercentage of memory used. Not supported on Windows.1Gauge
❌ container.memory.pgfaultIndicate the number of times that a process of the cgroup triggered a page fault.{faults}Counter
❌ container.memory.pgmajfaultIndicate the number of times that a process of the cgroup triggered a major fault.{faults}Counter
❌ container.memory.pgpginNumber of pages read from disk by the cgroup (Only available with cgroups v1).{operations}Counter
❌ container.memory.pgpgoutNumber of pages written to disk by the cgroup (Only available with cgroups v1).{operations}Counter
❌ container.memory.rssThe amount of memory that doesn’t correspond to anything on disk: stacks, heaps, and anonymous memory maps (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.rss_hugeNumber of bytes of anonymous transparent hugepages in this cgroup (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_active_anonThe amount of anonymous memory that has been identified as active by the kernel. Includes descendant cgroups (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_active_fileCache memory that has been identified as active by the kernel. Includes descendant cgroups (Only available with cgroups v1).ByUpDownCounter
βœ… container.memory.total_cacheTotal amount of memory used by the processes of this cgroup (and descendants) that can be associated with a block on a block device. Also accounts for memory used by tmpfs (Only available with cgroups v1). Not supported on Windows.ByUpDownCounter
❌ container.memory.total_dirtyBytes that are waiting to get written back to the disk, from this cgroup and descendants (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_inactive_anonThe amount of anonymous memory that has been identified as inactive by the kernel. Includes descendant cgroups (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_inactive_fileCache memory that has been identified as inactive by the kernel. Includes descendant cgroups (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_mapped_fileIndicates the amount of memory mapped by the processes in the control group and descendant groups (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_pgfaultIndicate the number of times that a process of the cgroup (or descendant cgroups) triggered a page fault (Only available with cgroups v1).{faults}Counter
❌ container.memory.total_pgmajfaultIndicate the number of times that a process of the cgroup (or descendant cgroups) triggered a major fault (Only available with cgroups v1).{faults}Counter
❌ container.memory.total_pgpginNumber of pages read from disk by the cgroup and descendant groups (Only available with cgroups v1).{operations}Counter
❌ container.memory.total_pgpgoutNumber of pages written to disk by the cgroup and descendant groups (Only available with cgroups v1).{operations}Counter
❌ container.memory.total_rssThe amount of memory that doesn’t correspond to anything on disk: stacks, heaps, and anonymous memory maps. Includes descendant cgroups (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_rss_hugeNumber of bytes of anonymous transparent hugepages in this cgroup and descendant cgroups (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_unevictableThe amount of memory that cannot be reclaimed. Includes descendant cgroups (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.total_writebackNumber of bytes of file/anon cache that are queued for syncing to disk in this cgroup and descendants (Only available with cgroups v1).ByUpDownCounter
❌ container.memory.unevictableThe amount of memory that cannot be reclaimed.ByUpDownCounter
βœ… container.memory.usage.limitMemory limit of the container. Not supported on Windows.ByUpDownCounter
❌ container.memory.usage.maxMaximum memory usage.ByUpDownCounter
βœ… container.memory.usage.totalMemory usage of the container. This excludes the cache.ByUpDownCounter
❌ container.memory.writebackNumber of bytes of file/anon cache that are queued for syncing to disk in this cgroup (Only available with cgroups v1).ByUpDownCounter
βœ… container.network.io.usage.rx_bytesBytes received by the container.ByCounterinterface
βœ… container.network.io.usage.rx_droppedIncoming packets dropped.{packets}Counterinterface
❌ container.network.io.usage.rx_errorsReceived errors. Not supported on Windows.{errors}Counterinterface
❌ container.network.io.usage.rx_packetsPackets received.{packets}Counterinterface
βœ… container.network.io.usage.tx_bytesBytes sent.ByCounterinterface
βœ… container.network.io.usage.tx_droppedOutgoing packets dropped.{packets}Counterinterface
❌ container.network.io.usage.tx_errorsSent errors. Not supported on Windows.{errors}Counterinterface
❌ container.network.io.usage.tx_packetsPackets sent.{packets}Counterinterface
❌ container.pids.countNumber of pids in the container’s cgroup.{pids}UpDownCounter
❌ container.pids.limitMaximum number of pids in the container’s cgroup.{pids}UpDownCounter
❌ container.restartsNumber of restarts for the container.{restarts}Counter
❌ container.uptimeTime elapsed since container start time.sGauge

Attributes

Attribute NameDescriptionTypeValues
coreThe CPU core number when utilising per-CPU metrics.string
device_majorDevice major number for block IO operations.string
device_minorDevice minor number for block IO operations.string
interfaceNetwork interface.string
operationType of BlockIO operation.string

Resource Attributes

Attribute NameDescriptionTypeEnabled
container.command_lineThe full command executed by the container.string❌
container.hostnameThe hostname of the container.stringβœ…
container.idThe ID of the container.stringβœ…
container.image.idThe ID of the container image.string❌
container.image.nameThe name of the docker image in use by the container.stringβœ…
container.nameThe name of the container.stringβœ…
container.runtimeThe runtime of the container. For this receiver, it will always be β€˜docker’.stringβœ…

Configuration

Example Configuration

docker_stats:
docker_stats/tls:
  endpoint: https://example.com/
  tls:
    insecure_skip_verify: true
docker_stats/allsettings:
  endpoint: http://example.com/
  collection_interval: 2s
  timeout: 20s
  api_version: '1.40'
  container_labels_to_metric_labels:
    my.container.label: my-metric-label
    my.other.container.label: my-other-metric-label
  env_vars_to_metric_labels:
    MY_ENVIRONMENT_VARIABLE: my-metric-label
    MY_OTHER_ENVIRONMENT_VARIABLE: my-other-metric-label
  excluded_images:
    - undesired-container
    - another-*-container
  metrics:
    container.cpu.usage.system:
      enabled: false
    container.memory.total_rss:
      enabled: true

Last generated: 2026-04-13