From 58b50a0b80ef1c42b01f488d437d4dc6b63f57d9 Mon Sep 17 00:00:00 2001 From: chesedo Date: Fri, 24 Feb 2023 12:15:39 +0200 Subject: [PATCH 1/2] feat: OpenTelemetry collector --- docker-compose.yml | 14 +++++-------- extras/otel/otel-collector-config.yaml | 28 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 extras/otel/otel-collector-config.yaml diff --git a/docker-compose.yml b/docker-compose.yml index 4c0454f05..ff41d949a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -157,21 +157,17 @@ services: placement: constraints: - node.hostname==postgres - datadog-agent: - image: datadog/agent + otel-collector: + image: otel/opentelemetry-collector-contrib:0.72.0 + command: [--config=/etc/otel-collector-config.yaml] + volumes: + - ./extras/otel/otel-collector-config.yaml:/etc/otel-collector-config.yaml restart: always networks: user-net: - volumes: - # Pull docker stats - - /var/run/docker.sock:/var/run/docker.sock:ro environment: - - DD_APM_ENABLED=true - - DD_APM_NON_LOCAL_TRAFFIC=true - - DD_SITE=datadoghq.eu - DD_API_KEY=${DD_API_KEY} - DD_ENV=${DD_ENV} - - DD_CONTAINER_LABELS_AS_TAGS={"project.name":"project_name"} deploy: placement: constraints: diff --git a/extras/otel/otel-collector-config.yaml b/extras/otel/otel-collector-config.yaml new file mode 100644 index 000000000..9bb9470bc --- /dev/null +++ b/extras/otel/otel-collector-config.yaml @@ -0,0 +1,28 @@ +receivers: + otlp: + protocols: + grpc: + +processors: + batch: + attributes: + actions: + - key: env + value: $(env:DD_ENV) + action: insert + +exporters: + datadog: + api: + site: datadoghq.eu + key: ${env:DD_API_KEY} +service: + pipelines: + traces: + receivers: [otlp] + processors: [attributes,batch] + exporters: [datadog] + logs: + receivers: [otlp] + processors: [attributes,batch] + exporters: [datadog] From fb2114dcf9c1579f7b167e32b9052c58f673e225 Mon Sep 17 00:00:00 2001 From: chesedo Date: Fri, 24 Feb 2023 13:10:30 +0200 Subject: [PATCH 2/2] feat: system stats --- docker-compose.yml | 2 ++ extras/otel/otel-collector-config.yaml | 39 ++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index ff41d949a..4f15f180f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -162,6 +162,8 @@ services: command: [--config=/etc/otel-collector-config.yaml] volumes: - ./extras/otel/otel-collector-config.yaml:/etc/otel-collector-config.yaml + # Pull docker stats + - /var/run/docker.sock:/var/run/docker.sock:ro restart: always networks: user-net: diff --git a/extras/otel/otel-collector-config.yaml b/extras/otel/otel-collector-config.yaml index 9bb9470bc..0b1526a8d 100644 --- a/extras/otel/otel-collector-config.yaml +++ b/extras/otel/otel-collector-config.yaml @@ -2,6 +2,37 @@ receivers: otlp: protocols: grpc: + # The hostmetrics receiver is required to get correct infrastructure metrics in Datadog. + hostmetrics: + collection_interval: 10s + scrapers: + paging: + metrics: + system.paging.utilization: + enabled: true + cpu: + metrics: + system.cpu.utilization: + enabled: true + disk: + filesystem: + metrics: + system.filesystem.utilization: + enabled: true + load: + memory: + network: + processes: + # The prometheus receiver scrapes metrics needed for the OpenTelemetry Collector Dashboard. + prometheus/otel: + config: + scrape_configs: + - job_name: 'otelcol' + scrape_interval: 10s + static_configs: + - targets: ['0.0.0.0:8888'] + docker_stats: + endpoint: unix:///var/run/docker.sock processors: batch: @@ -20,9 +51,13 @@ service: pipelines: traces: receivers: [otlp] - processors: [attributes,batch] + processors: [attributes, batch] exporters: [datadog] logs: receivers: [otlp] - processors: [attributes,batch] + processors: [attributes, batch] + exporters: [datadog] + metrics: + receivers: [hostmetrics, prometheus/otel, docker_stats, otlp] + processors: [batch] exporters: [datadog]