Skip to content

feat[datadog_metric_tag_configuration]: add data source#3783

Open
mdb wants to merge 1 commit into
DataDog:masterfrom
mdb:mdb/metric-tag-configuration-ds
Open

feat[datadog_metric_tag_configuration]: add data source#3783
mdb wants to merge 1 commit into
DataDog:masterfrom
mdb:mdb/metric-tag-configuration-ds

Conversation

@mdb
Copy link
Copy Markdown
Contributor

@mdb mdb commented May 13, 2026

Addresses #3790 to implement a datadog_metric_tag_configuration by using the ListTagConfigurationByName endpoint
(GET /api/v2/metrics/{metric_name}/tags) to surface "does a tag configuration exist for this metric?"

None of the existing metric data sources offer this insight:

  • datadog_metric_tags returns ingested tag values, unrelated to the managed tag configuration.
  • datadog_metric_metadata returns metric metadata, also unrelated.
  • datadog_metric_active_tags_and_aggregations returns active ingested data, also unrelated.

The data source returns successfully on 404 with exists = false rather than emitting a diagnostic error. This is a deliberate deviation from the convention used by e.g. data_source_datadog_incident_type, becaus one purpose served by this data source is existence checking — a data source that errors when its target doesn't exist cannot be used inside a for_each filter to discriminate.

Example motivating use case (other examples exist; this is just one):

Callers that dynamically discover metric names via datadog_metrics and want to import {} the subset that already have a tag configuration. Today, that import fails when any discovered metric lacks a tag configuration; this data source lets callers filter on .exists before populating the for_each set.

Wraps the ListTagConfigurationByName endpoint
(GET /api/v2/metrics/{metric_name}/tags), which is the only API that
authoritatively answers "does a tag configuration exist for this
metric?". None of the existing metric data sources do:

- datadog_metric_tags returns ingested tag values, unrelated to the
  managed tag configuration.
- datadog_metric_metadata returns metric metadata, also unrelated.
- datadog_metric_active_tags_and_aggregations returns active ingested
  data, also unrelated.

The data source returns successfully on 404 with exists = false rather
than emitting a diagnostic error. This is a deliberate deviation from
the convention used by e.g. data_source_datadog_incident_type, because
the one purpose served by this data source is existence checking — a data
source that errors when its target doesn't exist cannot be used inside
a for_each filter to discriminate.

Motivating use case: callers that dynamically discover metric names
via datadog_metrics and want to import {} the subset that already have
a tag configuration. Today that import fails when any discovered
metric lacks a tag configuration; this data source lets callers filter
on .exists before populating the for_each set.

Signed-off-by: Mike Ball <mikedball@gmail.com>
@mdb mdb marked this pull request as ready for review May 15, 2026 09:01
@mdb mdb requested review from a team as code owners May 15, 2026 09:01
@mdb
Copy link
Copy Markdown
Contributor Author

mdb commented May 17, 2026

@cswatt Thanks for the review! What are next steps for stewarding this along towards being merged/released? Anything I can help with?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants