• /
  • EnglishEspañolFrançais日本語한국어Português
  • 로그인지금 시작하기

Install and configure OpenTelemetry Collector Contrib to monitor Docker

|View as Markdown (English)

This page installs OpenTelemetry Collector Contrib on a Linux host, configures it to collect Docker container metrics, and verifies data reaches New Relic.

Compatibility and requirements

Supported

  • Docker Engine API version 1.25 or later

You need

  • A valid New Relic license key
  • Access to the Docker socket (typically /var/run/docker.sock)
  • Network access from the host to the Docker Engine socket and to a New Relic OTLP endpoint
  • Read permissions on /var/lib/docker/containers/ for log collection (typically root or docker group membership)

Install OpenTelemetry Collector Contrib

팁

If you already have OpenTelemetry Collector Contrib installed, skip this step and continue to Set up Docker socket permissions.

Download and install the OpenTelemetry Collector Contrib following the official installation guide.

Set up Docker socket permissions

The collector needs access to the Docker socket to collect container metrics. Grant the collector user access to the Docker group.

bash
$
# Add otelcol-contrib user to docker group
$
sudo usermod -aG docker otelcol-contrib
$
$
# Verify the user was added
$
groups otelcol-contrib
$
$
# Restart Docker to apply group changes
$
sudo systemctl restart docker
$
$
# Test Docker socket access
$
sudo -u otelcol-contrib docker ps

If the test command succeeds and shows your containers, you've configured permissions correctly.

If this reports permission denied instead of listing containers, see Permission denied errors.

Configure the collector

For OpenTelemetry Collector Contrib, merge the receivers, processors, exporters, and service pipelines into your configuration file (typically /etc/otelcol-contrib/config.yaml).

receivers:
# Docker Stats Receiver - collects container metrics
docker_stats:
endpoint: unix:///var/run/docker.sock
collection_interval: 15s
timeout: 5s
api_version: "1.25"
# Most metrics required for New Relic UI are enabled by default:
# CPU: container.cpu.usage.total, container.cpu.utilization
# Memory: container.memory.usage.total, container.memory.percent
# Network: container.network.io.usage.tx_bytes, container.network.io.usage.rx_bytes
# container.network.io.usage.tx_dropped, container.network.io.usage.rx_dropped
# Storage: container.blockio.io_service_bytes_recursive
#
# The following metrics need to be explicitly enabled:
metrics:
# Required for New Relic UI
container.pids.count:
enabled: true
# Additional network error metrics
container.network.io.usage.tx_errors:
enabled: true
container.network.io.usage.rx_errors:
enabled: true
processors:
# Resource detection - adds host metadata
resourcedetection:
detectors: [system, docker]
system:
resource_attributes:
host.name:
enabled: true
host.id:
enabled: true
# Batch processor - optimizes data transmission
batch:
timeout: 30s
send_batch_size: 512
# Transform processor - removes descriptions and units
transform:
metric_statements:
- context: metric
statements:
- set(description, "")
- set(unit, "")
exporters:
# New Relic OTLP Exporter
otlp_http/newrelic:
endpoint: ${env:NEWRELIC_OTLP_ENDPOINT}
headers:
api-key: ${env:NEWRELIC_LICENSE_KEY}
compression: gzip
timeout: 30s
retry_on_failure:
enabled: true
initial_interval: 5s
max_interval: 30s
max_elapsed_time: 300s
service:
pipelines:
metrics:
receivers: [docker_stats]
processors: [resourcedetection, transform, batch]
exporters: [otlp_http/newrelic]

Configuration parameters

The following table describes the key configuration parameters for the docker_stats receiver and exporter:

ParameterDescription
endpoint (docker_stats)Enter the path to the Docker socket the collector connects to. Default: unix:///var/run/docker.sock
collection_intervalSet how often the collector scrapes container stats. Default: 15s
timeoutSet how long the collector waits for the Docker Engine API to respond before giving up. Default: 5s
api_versionEnter the Docker Engine API version your host supports. Default: 1.25
NEWRELIC_LICENSE_KEYEnter your New Relic license key.
NEWRELIC_OTLP_ENDPOINTEnter the New Relic OTLP endpoint for your region. See New Relic OTLP endpoints.

Save the file and ensure the otelcol-contrib system user can read it.

팁

Optionally, you can also collect logs from your containers. For configuration steps, see Advanced configuration.

Configure the systemd service:

Now you'll configure the OpenTelemetry Collector Contrib service with your authentication credentials. This involves setting environment variables for your New Relic license key and OTLP endpoint.

  1. Create a systemd override directory:

    bash
    $
    sudo mkdir -p /etc/systemd/system/otelcol-contrib.service.d
  2. Create environment.conf with your configuration. Replace YOUR_LICENSE_KEY with your New Relic license key and YOUR_OTLP_ENDPOINT with the appropriate endpoint for your region:

    bash
    $
    cat <<EOF | sudo tee /etc/systemd/system/otelcol-contrib.service.d/environment.conf
    $
    [Service]
    $
    Environment="NEWRELIC_LICENSE_KEY=YOUR_LICENSE_KEY"
    $
    Environment="NEWRELIC_OTLP_ENDPOINT=YOUR_OTLP_ENDPOINT"
    $
    EOF

Restart the collector

Reload systemd and restart the collector:

bash
$
sudo systemctl daemon-reload
$
sudo systemctl restart otelcol-contrib
$
$
# Verify the collector is running
$
sudo systemctl status otelcol-contrib

Verify your install

Within 5 minutes of completing the install, confirm data reaches New Relic.

  • Go to one.newrelic.com > All Entities and search by hostname or container name. Your Docker containers should appear as entities.
  • Run this NRQL query and confirm it returns at least 1 row:
    FROM Metric SELECT count(*) WHERE container.runtime = 'docker' SINCE 10 minutes ago

If you don't see data within 5 minutes, see Docker monitoring troubleshooting.

Your Docker containers are reporting data. Want to collect logs too? Advanced configuration covers log collection setup.

Copyright © 2026 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.