Skip to content

[datadog_metric_active_tags_and_aggregations] data source silently returns empty results #3791

Description

@mdb

Datadog Terraform Provider Version

v3.91.0 (also reproduces against master at HEAD as of 2026-05-15)

Terraform Version

v1.9.7

What resources or data sources are affected?

  • datadog_metric_active_tags_and_aggregations (data source)

Terraform Configuration Files

terraform {
  required_providers {
    datadog = {
      source  = "DataDog/datadog"
      version = "~> 3.91"
    }
  }
}

provider "datadog" {}

# A metric known to have recent active data points and tags in your org.
# Replace with one that exists in your sandbox.
data "datadog_metric_active_tags_and_aggregations" "example" {
  metric = "system.cpu.idle"
}

output "active_tags" {
  value = data.datadog_metric_active_tags_and_aggregations.example.active_tags
}

output "active_aggregations" {
  value = data.datadog_metric_active_tags_and_aggregations.example.active_aggregations
}

Relevant debug or panic output

datadog_metric_active_tags_and_aggregations data source silently returns empty results because metric_name is sent to the API with literal quotes. There is no panic. The bug is silent: a successful read with empty results.

TF_LOG=DEBUG terraform plan 2>&1 > debug.log

The HTTP request line in the debug output reads (note the URL-encoded literal quotes around the metric name):

GET /api/v2/metrics/%22foo.bar%22/active-configurations

instead of:

GET /api/v2/metrics/foo.bar/active-configurations

Expected Behavior

For any metric with active data points in the last hour (the API's default window), the data source should return populated active_tags and active_aggregations. Calling the /api/v2/metrics/{metric_name}/active-configurations endpoint directly with curl confirms the API itself returns populated data:

curl -sH "DD-API-KEY: $DD_API_KEY" -H "DD-APPLICATION-KEY: $DD_APP_KEY" \
  "https://api.datadoghq.com/api/v2/metrics/foo.bar/active-configurations" \
  | jq '.data.attributes | {active_tags: (.active_tags | length), active_aggregations: (.active_aggregations | length)}'
{
  "active_tags": <non-zero>,
  "active_aggregations": <non-zero>
}

Actual Behavior

The data source successfully returns, but active_tags and active_aggregations are always [], regardless of the metric.

$ terraform apply -auto-approve
...
Outputs:

active_aggregations = tolist([])
active_tags = tolist([])

This was confirmed in my testing by exercising the data source against multiple known-active metrics. Both active_tags and active_aggregations returned [] for every tested metric, while the underlying REST endpoint returns populated data when called directly with the unquoted metric name.

Steps to Reproduce

  1. Save the configuration above as main.tf.
  2. terraform init
  3. terraform apply -auto-approve
  4. Observe: active_tags = tolist([]) and active_aggregations = tolist([]).
  5. Compare against curl ... /api/v2/metrics/foo.bar/active-configurations, which returns populated data for the same metric.

Important Factoids

Fixed via #3782

References

Fixed via #3782

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions