You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Datadog APM追踪标签仅带@前缀,如何映射至REGION列?

问题

我正尝试为Datadog中的APM追踪添加region标签,我的服务以ECS任务形式运行,期望能按region过滤APM追踪。我已在任务定义中添加{ name = "DD_TAGS", value = "region:${var.region}" }配置,目前能在追踪中看到region:us-west-1,但在Datadog UI中仅能通过@region:us-west-1进行过滤,且该标签显示在AWS SERVICE REGION列中。

我的ECS任务的Datadog配置如下:

// Datadog-specific configuration for service
{ name = "DD_SERVICE", value = "webapp" },
{ name = "DD_ENV", value = var.environment },
{ name = "DD_TAGS", value = "region:${var.region}" }, # this is the only tag that I am able to pass to APM traces
{ name = "DD_TRACE_CLI_ENABLED", value = "1" },
{ name = "DD_PROFILING_ENABLED", value = "1" },
{ name = "DD_DBM_PROPAGATION_MODE", value = "full" }

Datadog容器配置:

// "Environment" configuration
{ name = "DD_ENV", value = var.environment },
{ name = "DD_TAGS", value = "region:${var.aws_region},cluster:${var.ecs_cluster_name},task_name:${var.task_name}" },

// "Global" configuration
{ name = "DD_API_KEY", value = var.datadog_api_key },
{ name = "DD_SITE", value = "datadoghq.com" },
{ name = "DD_DOGSTATSD_NON_LOCAL_TRAFFIC", value = "true" }, // Allow statsd from other containers
{ name = "DD_AC_EXCLUDE", value = "name:datadog-ecs-agent" },

// Enabled Features
{ name = "DD_LOGS_ENABLED", value = "true" },
{ name = "DD_APM_ENABLED", value = "true" },
{ name = "DD_PROCESS_AGENT_ENABLED", value = "true" },

{ name = "DD_LOGS_CONFIG_AUTO_MULTI_LINE_DETECTION", value = "true" }

请问是否有办法将该region标签应用至REGION列?

解决方案

要让region标签映射到Datadog UI的REGION列,需要使用Datadog预定义的标准化标签键——将自定义的region标签替换为aws.region,这是Datadog识别并关联到REGION列的标准键。

具体修改步骤:

  1. 更新ECS任务定义中的DD_TAGS配置:
    { name = "DD_TAGS", value = "aws.region:${var.region}" },
    
  2. 同步修改Datadog容器配置中的DD_TAGS:
    { name = "DD_TAGS", value = "aws.region:${var.aws_region},cluster:${var.ecs_cluster_name},task_name:${var.task_name}" },
    
  3. 重启ECS任务和Datadog代理容器,使新配置生效。

配置生效后,新生成的APM追踪会自动将aws.region的值填充到REGION列中,你可以直接在UI的REGION筛选器中选择对应区域,无需使用@region语法过滤。

注意:历史追踪数据不会自动更新标签映射,只有配置修改后产生的新追踪才会显示在REGION列。

内容的提问来源于stack exchange,提问作者Maxim Ersov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 18:52:41