Skip to content

Conversation

@Mathew-Estafanous
Copy link
Contributor

@Mathew-Estafanous Mathew-Estafanous commented Oct 27, 2025

What does this PR do?

Adds USD docker labels to all container definitions including the datadog agent & customer's container definition.

configuration to docker label mapping:

  • dd_env -> com.datadoghq.tags.env
  • dd_service -> com.datadoghq.tags.service
  • dd_version -> com.datadoghq.tags.version

Motivation

ecs.fargate.cpu.limit and similar metrics don't have service/env/version tags despite setting UST env vars on all container environments. That's because UST tags cannot be created based on environment variables when deploying on ECS Fargate.

Adding UST docker labels fixes this such that metrics and logs are properly tagged with service/env/version.

Describe how you validated your changes

  • Added ust docker label tests ust_docker_labels_test.go.

Manual Testing

  1. Terraform apply with dd_service/dd_version/dd_env setup.
module "datadog_ecs_fargate_task" {
  source = "../../modules/ecs_fargate"

  # Configure Datadog
  dd_api_key                       = var.dd_api_key
  dd_site                          = var.dd_site
  dd_tags                          = "team:cont-p, owner:container-monitoring"
  dd_essential                     = true
  dd_is_datadog_dependency_enabled = true

  dd_service = "test-service"
  dd_env     = "test"
  dd_version = "1.2.3"

  dd_environment = [
    {
      name  = "DD_CUSTOM_FEATURE",
      value = "true",
    },
  ]

  dd_dogstatsd = {
    enabled                  = true
    dogstatsd_cardinality    = "high",
    origin_detection_enabled = true,
  }

  dd_apm = {
    enabled   = true,
    profiling = true,
  }

  dd_log_collection = {
    enabled = true,
  }

  dd_cws = {
    enabled = true,
  }

  # Configure Task Definition
  family = var.task_family_name
  container_definitions = jsonencode([
    {
      name      = "dummy-dogstatsd-app",
      image     = "ghcr.io/datadog/apps-dogstatsd:main",
      essential = false,
    },
    {
      name      = "dummy-apm-app",
      image     = "ghcr.io/datadog/apps-tracegen:main",
      essential = true,
    },
    {
      name      = "dummy-cws-app",
      image     = "public.ecr.aws/ubuntu/ubuntu:22.04_stable",
      essential = false,
      entryPoint = [
        "/usr/bin/bash",
        "-c",
        "cp /usr/bin/bash /tmp/malware; chmod u+s /tmp/malware; apt update;apt install -y curl wget; /tmp/malware -c 'while true; do wget https://google.com; sleep 60; done'"
      ],
    }
  ])
  volumes = [
    {
      name = "app-volume"
    }
  ]
  runtime_platform = {
    cpu_architecture        = "ARM64"
    operating_system_family = "LINUX"
  }
  requires_compatibilities = ["FARGATE"]
}
  1. Deploy task definition as service.
  2. Confirm ecs.fargate.cpu.limit metrics are tagged with UST tags.
image

Additional Notes

@Mathew-Estafanous Mathew-Estafanous added the enhancement New feature or request label Oct 27, 2025
@Mathew-Estafanous Mathew-Estafanous self-assigned this Oct 27, 2025
@Mathew-Estafanous Mathew-Estafanous changed the title [CONTP-1014] feat: Add UST docker labels to all container definitions. [CONTP-1014] feat: Add UST docker labels to all container definitions Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants