From e3b1bd4d1317f5fa42e2d804db844c75d53e9270 Mon Sep 17 00:00:00 2001 From: Sean Rankine Date: Mon, 6 Jul 2026 14:22:03 +0100 Subject: [PATCH] Add environment name to OTel metrics Set deployment.environment.name as a resource attribute in the ADOT collector metrics pipeline so metrics in CloudWatch can be filtered and grouped by environment (dev, staging, production). --- infra/modules/ecs-service/adot-collector-config.yaml.tpl | 7 ++++++- infra/modules/ecs-service/adot.tf | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/infra/modules/ecs-service/adot-collector-config.yaml.tpl b/infra/modules/ecs-service/adot-collector-config.yaml.tpl index af0ef0f5f..d226c5873 100644 --- a/infra/modules/ecs-service/adot-collector-config.yaml.tpl +++ b/infra/modules/ecs-service/adot-collector-config.yaml.tpl @@ -45,6 +45,11 @@ processors: enabled: false cloud.region: enabled: false + resource/env: + attributes: + - key: deployment.environment.name + value: ${env_name} + action: upsert exporters: awsxray: @@ -64,5 +69,5 @@ service: exporters: [awsxray] metrics: receivers: [otlp] - processors: [resourcedetection/ecs, batch/metrics] + processors: [resourcedetection/ecs, resource/env, batch/metrics] exporters: [otlphttp] diff --git a/infra/modules/ecs-service/adot.tf b/infra/modules/ecs-service/adot.tf index 28186717a..616453935 100644 --- a/infra/modules/ecs-service/adot.tf +++ b/infra/modules/ecs-service/adot.tf @@ -10,6 +10,7 @@ resource "aws_ssm_parameter" "adot_collector_config" { type = "String" value = templatefile("${path.module}/adot-collector-config.yaml.tpl", { aws_region = data.aws_region.current.region + env_name = var.env_name }) description = "OpenTelemetry collector configuration for the ${var.application} ADOT sidecar in ${var.env_name}"