DataDog / terraform-provider-datadog

Terraform Datadog provider
https://www.terraform.io/docs/providers/datadog/
Mozilla Public License 2.0
403 stars 380 forks source link

Add Cost Alert to Datadog Monitor Types #2675

Open OgonnaO opened 1 week ago

OgonnaO commented 1 week ago

What resources or data sources are affected?

resource "datadog_monitor" 

Feature Request

Requesting the addition of a cost alert monitor type in Datadog's Terraform provider. This would simplify setting up cost-related alerts directly through Terraform.

Use Case: Monitoring cloud spending is important for budget management. A dedicated cost alert type in Terraform would streamline the process, making it easier to set thresholds and detect anomalies.

Benefits:

resource "datadog_monitor" "cost_alert" {
  name    = "Monthly Cost Alert"
  type    = "cost alert"
  query   = formula("sum:gcp.cost.amortized{*}.rollup(sum, 86400)").last("30d").change("absolute") > 10000
  message = <<EOT
Alert: Monthly cost threshold exceeded for project {{project_name}}.

{{#is_alert}}
- Investigate recent changes in resource usage or configurations.
- The total cost has exceeded $5000 in the last 30 days.
- Current Cost: {{value}}
{{/is_alert}}

{{#is_no_data}}
Cost data is missing.
- Check if the billing export is functioning correctly.
- Verify if there are any service disruptions in GCP or Datadog.
- Ensure that the monitor's query is still valid.
{{/is_no_data}}
EOT
  thresholds {
    critical = 5000
  }
}

Conclusion: Adding a cost alert monitor type to Datadog's Terraform provider would enhance cloud cost management, making it easier to set up and manage cost-related alerts within IaC workflows.

References

Image