From 510cf55d52fe5051fdb033670e83416a53547c0e Mon Sep 17 00:00:00 2001 From: Eddy Decena Date: Mon, 25 Mar 2024 12:59:40 -0400 Subject: [PATCH] fix: Enable Datadog filtering for HMS/WD metrics on ECS with Apiary tags (#252) Co-authored-by: Eddy Perez --- common.tf | 2 ++ templates.tf | 2 ++ templates/apiary-hms-readonly.json | 4 ++++ templates/apiary-hms-readwrite.json | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/common.tf b/common.tf index 3c6f4e6..4990bcd 100644 --- a/common.tf +++ b/common.tf @@ -9,6 +9,8 @@ locals { apiary_bucket_prefix = "${local.instance_alias}-${data.aws_caller_identity.current.account_id}-${data.aws_region.current.name}" apiary_assume_role_bucket_prefix = [for assumerole in var.apiary_assume_roles : "${local.instance_alias}-${data.aws_caller_identity.current.account_id}-${lookup(assumerole, "allow_cross_region_access", false) ? "*" : data.aws_region.current.name}"] enable_route53_records = var.apiary_domain_name == "" ? false : true + + datadog_tags = join(" ", formatlist("%s:%s", keys(var.apiary_tags), values(var.apiary_tags))) # # Create a new list of maps with some extra attributes needed later # diff --git a/templates.tf b/templates.tf index f4b5941..8df9a3f 100644 --- a/templates.tf +++ b/templates.tf @@ -68,6 +68,7 @@ locals{ metrics_port = var.datadog_metrics_port datadog_agent_version = var.datadog_agent_version datadog_agent_enabled = var.datadog_agent_enabled + datadog_tags = local.datadog_tags }) hms_readonly_template = templatefile("${path.module}/templates/apiary-hms-readonly.json", { @@ -118,5 +119,6 @@ locals{ wd_instance_type = var.hms_instance_type metrics_port = var.datadog_metrics_port datadog_agent_version = var.datadog_agent_version + datadog_tags = local.datadog_tags }) } diff --git a/templates/apiary-hms-readonly.json b/templates/apiary-hms-readonly.json index 48d31ea..e2a8ab1 100644 --- a/templates/apiary-hms-readonly.json +++ b/templates/apiary-hms-readonly.json @@ -205,6 +205,10 @@ { "name": "ECS_FARGATE", "value": "true" + }, + { + "name": "DD_TAGS", + "value": "${datadog_tags}" } ] } diff --git a/templates/apiary-hms-readwrite.json b/templates/apiary-hms-readwrite.json index 20a4071..b9a98ec 100644 --- a/templates/apiary-hms-readwrite.json +++ b/templates/apiary-hms-readwrite.json @@ -257,6 +257,10 @@ { "name": "ECS_FARGATE", "value": "true" + }, + { + "name": "DD_TAGS", + "value": "${datadog_tags}" } ] }