terraform-provider-datadog icon indicating copy to clipboard operation
terraform-provider-datadog copied to clipboard

Add support to datadog_team datasource to know what services a team supports

Open markgholland opened this issue 10 months ago • 1 comments

What resources or data sources are affected?

datadog_team (Data Source)

Feature Request

It would be nice if the datadog_team data source returned a list of services linked to the team. This would be useful when setting up monitors so you could apply the monitor to each service and it would show as an "Enabled Monitor" on the Services page.

For example, in the below error tracking monitor, I have to maintain a list of services that I want to be linked to the service instead of just being able to get that data from the datadog_team data source:

locals {
  team_projects            = ["service_1", "service_2", "service_3"] //this goes away if I can get it from a datasource
  team_projects_filter     = join(" OR ", [for project in local.team_projects : project])
}

resource "datadog_monitor" "error_tracking_alert" {
  require_full_window = false
  name                = "New Error Detected in {{log.service}} (${var.env})"
  type                = "error-tracking alert"
  tags = concat(
    ["team:my-team", "env:${var.env}"],
    [for project in local.team_projects : "service:${project}"]
  )
  priority = 5
  query    = <<EOT
error-tracking-traces("(@issue.age:<=300000 OR @issue.regression.age:<=300000) service:(${local.team_projects_filter}) env:${var.env}").rollup("count").by("@issue.id").last("5m") > 0
EOT
  message  = <<EOT
  A new [issue]({{ issue.link }}) has been detected.
```{{issue.attributes.error.type}}: {{issue.attributes.error.message}}```

@[email protected]

Mark the issue as Reviewed to stop receiving this alert.
EOT

}

References

No response

markgholland avatar Feb 06 '25 18:02 markgholland

It will not be provided at team level but you can get the list of services owned by a team with

data "datadog_software_catalog" "test" {
   filter_owner = "myteam"
}

It relies on https://docs.datadoghq.com/software_catalog/

Doc of the resource

Is it answering your needs ?

ecdatadog avatar May 16 '25 12:05 ecdatadog