From ebc32b99fd557c2f9779dd452ca05c1e02f8b966 Mon Sep 17 00:00:00 2001 From: Juliano Costa Date: Tue, 2 Jul 2024 11:05:10 -0400 Subject: [PATCH] [otel-col] Add docker stats receiver (#1650) * Add docker stats receiver * changelog * Nit: prevent write access to the Docker socket Co-authored-by: Roger Coll * Add compose minimal --------- Co-authored-by: Roger Coll --- .env | 1 + CHANGELOG.md | 4 +++- docker-compose.minimal.yml | 2 ++ docker-compose.yml | 2 ++ src/otelcollector/otelcol-config.yml | 12 +++++++++++- 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 2300bc23c5..376653806d 100644 --- a/.env +++ b/.env @@ -22,6 +22,7 @@ TRACETEST_IMAGE=kubeshop/tracetest:v1.3.0 ENV_PLATFORM=local # OpenTelemetry Collector +DOCKER_SOCK=/var/run/docker.sock OTEL_COLLECTOR_HOST=otelcol OTEL_COLLECTOR_PORT_GRPC=4317 OTEL_COLLECTOR_PORT_HTTP=4318 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ed0d1876e..2cfc180f36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,8 +18,10 @@ the release. ([#1610](https://github.com/open-telemetry/opentelemetry-demo/pull/1610)) * [Valkey] Replace Redis with Valkey ([#1619](https://github.com/open-telemetry/opentelemetry-demo/pull/1619)) -* ([recommendation] updated flag name to match flagd configuration +* [recommendation] updated flag name to match flagd configuration ([#1634](https://github.com/open-telemetry/opentelemetry-demo/pull/1634)) +* [otel-col] Add docker stats receiver + ([#1650](https://github.com/open-telemetry/opentelemetry-demo/pull/1650)) ## 1.10.0 diff --git a/docker-compose.minimal.yml b/docker-compose.minimal.yml index 5720b4e0c8..b4925dd742 100644 --- a/docker-compose.minimal.yml +++ b/docker-compose.minimal.yml @@ -583,7 +583,9 @@ services: memory: 200M restart: unless-stopped command: [ "--config=/etc/otelcol-config.yml", "--config=/etc/otelcol-config-extras.yml" ] + user: 0:0 volumes: + - ${DOCKER_SOCK}:/var/run/docker.sock:ro - ${OTEL_COLLECTOR_CONFIG}:/etc/otelcol-config.yml - ${OTEL_COLLECTOR_CONFIG_EXTRAS}:/etc/otelcol-config-extras.yml ports: diff --git a/docker-compose.yml b/docker-compose.yml index 511883c21f..068eab39f7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -693,7 +693,9 @@ services: memory: 200M restart: unless-stopped command: [ "--config=/etc/otelcol-config.yml", "--config=/etc/otelcol-config-extras.yml" ] + user: 0:0 volumes: + - ${DOCKER_SOCK}:/var/run/docker.sock:ro - ${OTEL_COLLECTOR_CONFIG}:/etc/otelcol-config.yml - ${OTEL_COLLECTOR_CONFIG_EXTRAS}:/etc/otelcol-config-extras.yml ports: diff --git a/src/otelcollector/otelcol-config.yml b/src/otelcollector/otelcol-config.yml index f8a34399cd..8901737b5c 100644 --- a/src/otelcollector/otelcol-config.yml +++ b/src/otelcollector/otelcol-config.yml @@ -13,10 +13,20 @@ receivers: httpcheck/frontendproxy: targets: - endpoint: http://frontendproxy:${env:ENVOY_PORT} + docker_stats: + endpoint: unix:///var/run/docker.sock redis: endpoint: "valkey-cart:6379" username: "valkey" collection_interval: 10s + # Collector metrics + prometheus: + config: + scrape_configs: + - job_name: 'otelcol' + scrape_interval: 10s + static_configs: + - targets: ['0.0.0.0:8888'] exporters: debug: @@ -48,7 +58,7 @@ service: processors: [batch] exporters: [otlp, debug, spanmetrics] metrics: - receivers: [httpcheck/frontendproxy, redis, otlp, spanmetrics] + receivers: [docker_stats, httpcheck/frontendproxy, otlp, prometheus, redis, spanmetrics] processors: [batch] exporters: [otlphttp/prometheus, debug] logs: