You can collect metrics about your Docker containers with the OpenTelemetry collector. The collector is a component of OpenTelemetry that collects, processes, and exports telemetry data to New Relic (or any observability backend).
You can view this metric data in pre-built dashboards, create alert policies, and create custom queries and charts.
If you're looking for help with other collector use cases, see the newrelic-opentelemetry-examples repository.
Complete the steps below to collect metrics from docker containers:
The collector will use the dockerstats receiver component (minimum version recommended v0.81.0), and it requires access to the docker daemon through an endpoint:
- By default
unix:///var/run/docker.sockendpoint is used. Therefore, the collector should be executed with a user able to read the docker socket.
Download and install the Opentelemetry collector following Opentelemetry docs.
You will need to install OpenTelemetry Collector Contrib Distro or other distribution including, at least, the following components:
Update or create a new file called
config.yaml from the example below.
NEW_RELIC_LICENSE_KEY in the file with your own values. For more info, see the New Relic License key.
receivers:docker_stats:metrics:container.cpu.usage.total:enabled: truecontainer.cpu.throttling_data.periods:enabled: truecontainer.cpu.throttling_data.throttled_periods:enabled: true# `container.cpu.percent` is deprecated in favor of `container.cpu.utilization` in opentelemetry-collector-contrib v0.79.0container.cpu.utilization:enabled: truecontainer.cpu.percent:enabled: falsecontainer.memory.usage.limit:enabled: truecontainer.memory.usage.total:enabled: truecontainer.memory.percent:enabled: truecontainer.blockio.io_service_bytes_recursive:enabled: truecontainer.network.io.usage.rx_bytes:enabled: truecontainer.network.io.usage.tx_bytes:enabled: truecontainer.network.io.usage.rx_dropped:enabled: truecontainer.network.io.usage.tx_dropped:enabled: truecontainer.network.io.usage.rx_errors:enabled: truecontainer.network.io.usage.tx_errors:enabled: truecontainer.network.io.usage.rx_packets:enabled: truecontainer.network.io.usage.tx_packets:enabled: truecontainer.pids.count:enabled: trueprocessors:# resource and resource-detection processors allow decorating the metrics with host attributesresource:attributes:- key: host.idfrom_attribute: host.nameaction: insertresourcedetection:detectors: ["env", "system"]resourcedetection/cloud:detectors: ["gcp", "ec2", "azure"]timeout: 2soverride: falseexporters:otlp:endpoint: https://otlp.nr-data.net:443headers:api-key: NEW_RELIC_LICENSE_KEYservice:telemetry:logs:pipelines:metrics:receivers: [docker_stats]processors:- resourcedetection- resourcedetection/cloud- resourceexporters: [otlp]
For further configuration options, please review:
Run the Opentelemetry collector (the way to run it may vary depending on the chosen installation method). Example:
/usr/bin/otelcol-contrib --config ./config.yaml
The container's telemetry data originating from the Open Telemetry Docker receiver generates container entities. Entities are anything that reports data to New Relic and is identified by an unique entity ID.
Your monitored entities are the drivers of features like Entity Explorer, Workloads, and Lookout. Check this document for more information on how to get benefited from these experiences.
You may use the metrics explorer to check the metrics being ingested. All metrics reported by the docker stats receiver start by the
The following NRQL queries show examples to help you query the metrics you received:
Listing number of metric updates ingested by metric name:SELECT count(*) FROM Metric WHERE metricName LIKE 'container.%' and instrumentation.provider='opentelemetry' facet metricName LIMIT max
Querying a specific metric faceted by host:SELECT average(container.cpu.percent) FROM Metric WHERE instrumentation.provider='opentelemetry' FACET host.name TIMESERIES
Listing dimensions available for a given metric:SELECT keyset() FROM Metric WHERE metricName = 'container.cpu.percent'
Take advantage of the Docker dashboard included in the Docker Open Telemetry Quickstart to easily monitor your Docker infrastructure thanks to the predefined graphs and filters.
For a list of all the supported metrics, please refer to the dockerstats receiver metrics reference.