OTel Collector on Docker
Deploy the OpenTelemetry Collector as a Docker container to forward traces, metrics, and logs to Kloudfuse. The collector receives telemetry from your application containers over OTLP and exports it to the Kloudfuse ingester endpoints.
Prerequisites
-
Docker or Docker Compose installed on your host.
-
The external hostname of your Kloudfuse cluster.
-
If ingestion authentication is enabled, an API key — see Ingestion Authentication with API Key.
Basic Configuration
The following config.yaml configures the OTel Collector to receive OTLP data and export traces, metrics, and logs to Kloudfuse.
Set kf_platform to docker so that Kloudfuse associates telemetry with Docker infrastructure:
receivers:
otlp:
protocols:
grpc:
http:
cors:
allowed_origins:
- "http://*"
- "https://*"
exporters:
otlphttp:
logs_endpoint: https://<kloudfuse-hostname>/ingester/otlp/v1/logs
metrics_endpoint: https://<kloudfuse-hostname>/ingester/otlp/metrics
traces_endpoint: https://<kloudfuse-hostname>/ingester/otlp/traces
headers:
Kf-Api-Key: <token> # omit if auth is not enabled
processors:
batch:
timeout: 10s
resource:
attributes:
- key: kf_platform (1)
value: "docker"
action: upsert
resourcedetection:
detectors:
- env
- docker
- ec2
- gcp
- azure
override: true
timeout: 2s
connectors:
spanmetrics:
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch, resource, resourcedetection]
exporters: [otlphttp]
metrics:
receivers: [otlp]
processors: [batch, resource, resourcedetection]
exporters: [otlphttp]
logs:
receivers: [otlp]
processors: [batch, resource, resourcedetection]
exporters: [otlphttp]
| 1 | kf_platform: docker is a required resource attribute. Kloudfuse uses it to link APM data to Docker infrastructure metrics. |
Docker Resource Detector
The Docker resource detector reads the host hostname from the Docker daemon and sets it as the host.name resource attribute.
This requires that the OTel Collector can read the Docker socket.
When running the collector with Docker Compose, mount the socket as read-only and set the group to match:
services:
otelcol:
image: otel/opentelemetry-collector-contrib
volumes:
- ./config.yaml:/etc/otelcol-contrib/config.yaml
- type: bind
source: /var/run/docker.sock
target: /var/run/docker.sock
read_only: true
user: "10001:<docker-socket-gid>" (1)
| 1 | Replace <docker-socket-gid> with the group ID of /var/run/docker.sock. Find it with: stat -c '%g' /var/run/docker.sock |
Docker and System-Level Metrics
Kloudfuse APM Services correlate APM data with host infrastructure metrics on the Infra tab of a service detail page.
To enable this, add the docker_stats and hostmetrics receivers and the kf_metrics_agent resource attribute to your configuration:
receivers:
otlp:
protocols:
grpc:
http:
cors:
allowed_origins:
- "http://*"
- "https://*"
docker_stats:
hostmetrics:
collection_interval: 30s
scrapers:
cpu:
metrics:
system.cpu.utilization:
enabled: true
memory:
metrics:
system.memory.utilization:
enabled: true
disk:
filesystem:
metrics:
system.filesystem.utilization:
enabled: true
exporters:
otlphttp:
logs_endpoint: https://<kloudfuse-hostname>/ingester/otlp/v1/logs
metrics_endpoint: https://<kloudfuse-hostname>/ingester/otlp/metrics
traces_endpoint: https://<kloudfuse-hostname>/ingester/otlp/traces
headers:
Kf-Api-Key: <token> # omit if auth is not enabled
processors:
batch:
timeout: 10s
resource:
attributes:
- key: kf_platform
value: "docker"
action: upsert
- key: kf_metrics_agent (1)
value: "otlp"
action: upsert
resourcedetection:
detectors:
- env
- docker
- ec2
- gcp
- azure
override: true
timeout: 2s
service:
pipelines:
traces:
receivers: [otlp]
processors: [batch, resource, resourcedetection]
exporters: [otlphttp]
metrics:
receivers: [otlp, docker_stats, hostmetrics]
processors: [batch, resource, resourcedetection]
exporters: [otlphttp]
logs:
receivers: [otlp]
processors: [batch, resource, resourcedetection]
exporters: [otlphttp]
| 1 | kf_metrics_agent: otlp tells Kloudfuse to associate these host metrics with the OTel collector, enabling correlation in the APM Services Infra tab. |
Related Pages
-
OpenTelemetry Runtime Metrics — collect Node.js runtime metrics alongside application traces