From 32da99e3ec7b2fe346ad095898ed0ff529947ab7 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 16 Mar 2025 19:49:35 +0100 Subject: [PATCH] Add docker-compose file for Datadog and OpenTelemetry setup Introduce a new docker-compose configuration to integrate Datadog and OpenTelemetry with services like PostgreSQL, RabbitMQ, Redis, and Elsa. Updated the Datadog API key in an existing compose file for security purposes. This setup enables detailed monitoring, tracing, and metrics collection for development environments. --- .../docker-compose-datadog+otel-collector.yml | 115 ++++++++++++++++++ docker/docker-compose-datadog.yml | 2 +- 2 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 docker/docker-compose-datadog+otel-collector.yml diff --git a/docker/docker-compose-datadog+otel-collector.yml b/docker/docker-compose-datadog+otel-collector.yml new file mode 100644 index 000000000..20a056580 --- /dev/null +++ b/docker/docker-compose-datadog+otel-collector.yml @@ -0,0 +1,115 @@ +services: + postgres: + image: postgres:latest + command: -c 'max_connections=2000' + environment: + POSTGRES_USER: elsa + POSTGRES_PASSWORD: elsa + POSTGRES_DB: elsa + volumes: + - postgres-data:/var/lib/postgresql/data + ports: + - "5432:5432" + + rabbitmq: + image: "rabbitmq:3-management" + ports: + - "15672:15672" + - "5672:5672" + + redis: + image: redis:latest + ports: + - "127.0.0.1:6379:6379" + + elsa-server: + pull_policy: always + build: + context: ../. + dockerfile: ./docker/ElsaServer-Datadog.Dockerfile + depends_on: + - postgres + - rabbitmq + - redis + - otel-collector + environment: + DD_AGENT_HOST: datadog-agent + DD_ENV: development + DD_TRACE_DEBUG: true + DD_TRACE_OTEL_ENABLED: true + DD_SERVICE: "Elsa Server" + DD_VERSION: "3.3.0" + # OpenTelemetry environment variables + OTEL_EXPORTER_OTLP_ENDPOINT: "http://otel-collector:4317" # Point to OpenTelemetry Collector + OTEL_EXPORTER_OTLP_PROTOCOL: "grpc" # Use gRPC for OTLP + OTEL_TRACES_EXPORTER: "otlp" + OTEL_METRICS_EXPORTER: "otlp" + OTEL_LOGS_EXPORTER: "otpl" + OTEL_RESOURCE_ATTRIBUTES: "service.name=elsa-server-local,service.version=3.2.1-blueberry,deployment.environment=development" + OTEL_DOTNET_AUTO_TRACES_ADDITIONAL_SOURCES: "Elsa.Workflows" + OTEL_DOTNET_AUTO_INSTRUMENTATION_ENABLED: "true" + OTEL_LOG_LEVEL: "debug" + OTEL_DOTNET_AUTO_RESOURCE_DETECTOR_ENABLED: "true" + OTEL_DOTNET_AUTO_LOGS_CONSOLE_EXPORTER_ENABLED: "true" + OTEL_DOTNET_AUTO_METRICS_CONSOLE_EXPORTER_ENABLED: "true" + OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED: "true" + + ASPNETCORE_ENVIRONMENT: Development + PYTHONNET_PYDLL: /opt/homebrew/Cellar/python@3.11/3.11.6_1/Frameworks/Python.framework/Versions/3.11/bin/python3.11 + PYTHONNET_RUNTIME: coreclr + CONNECTIONSTRINGS__POSTGRESQL: "Server=postgres;Username=elsa;Database=elsa;Port=5432;Password=elsa;SSLMode=Prefer" + CONNECTIONSTRINGS__RABBITMQ: "amqp://guest:guest@rabbitmq:5672/" + CONNECTIONSTRINGS__REDIS: "redis:6379" + DISTRIBUTEDLOCKPROVIDER: "Postgres" + ports: + - "13000:8080" + + elsa-studio: + pull_policy: always + build: + context: ../. + dockerfile: ./docker/ElsaStudio.Dockerfile + environment: + ASPNETCORE_ENVIRONMENT: Development + ELSASERVER__URL: "http://localhost:13000/elsa/api" + ports: + - "14000:8080" + + otel-collector: + image: otel/opentelemetry-collector-contrib:latest + volumes: + - ./otel-collector-config.yaml:/etc/otel-collector-config.yaml + command: [ "--config", "/etc/otel-collector-config.yaml", "--feature-gates", "-component.UseLocalHostAsDefaultHost" ] + environment: + DD_API_KEY: "secret api key" + DD_SITE: "datadoghq.eu" + ports: + - "13133:13133" + - "4317:4317" + - "4318:4318" + + datadog-agent: + image: datadog/agent:latest + environment: + DD_API_KEY: "" + DD_SITE: "datadoghq.eu" + DD_HOSTNAME: "otel-collector" + DD_LOGS_ENABLED: "true" + DD_OTLP_CONFIG_LOGS_ENABLED: "true" + DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL: "true" + DD_APM_ENABLED: "true" + DD_APM_NON_LOCAL_TRAFFIC: "true" + DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_GRPC_ENDPOINT: 0.0.0.0:4317 # The Datadog Agent expects traces from OpenTelemetry Collector + DD_OTLP_CONFIG_RECEIVER_PROTOCOLS_HTTP_ENDPOINT: 0.0.0.0:4318 + + # Service autodiscovery + DD_AC_INCLUDE: "name:postgres,name:rabbitmq,name:redis,name:elsa-server" + DD_AC_EXCLUDE: "name:datadog-agent" + + ports: + - "8126:8126" + - "14317:4317" + - "14318:4318" + +volumes: + postgres-data: \ No newline at end of file diff --git a/docker/docker-compose-datadog.yml b/docker/docker-compose-datadog.yml index 54b2098e5..23c42357d 100644 --- a/docker/docker-compose-datadog.yml +++ b/docker/docker-compose-datadog.yml @@ -41,7 +41,7 @@ services: datadog-agent: image: gcr.io/datadoghq/agent:7 environment: - DD_API_KEY: "b430503d709680c951cfe3979ae35068" + DD_API_KEY: "" DD_SITE: "datadoghq.eu" DD_HOSTNAME: "datadog-agent" DD_LOGS_ENABLED: "true"