azurerm_datadog_monitor

Manages a datadog Monitor.

Example Usage

Monitor creation with linking to Datadog organization

resource "azurerm_resource_group" "example" {
  name     = "example-datadog"
  location = "West US 2"
}
resource "azurerm_datadog_monitor" "example" {
  name                = "example-monitor"
  resource_group_name = azurerm_resource_group.example.name
  location            = azurerm_resource_group.example.location
  datadog_organization {
    api_key         = "XXXX"
    application_key = "XXXX"
  }
  user {
    name  = "Example"
    email = "abc@xyz.com"
  }
  sku_name = "Linked"
  identity {
    type = "SystemAssigned"
  }
}

Arguments Reference

The following arguments are supported:


A datadog_organization block exports the following:


An identity block supports the following:

NOTE: The assigned principal_id and tenant_id can be retrieved after the identity type has been set to SystemAssigned and the Datadog Monitor has been created. More details are available below.


An user block exports the following:

Attributes Reference

In addition to the Arguments listed above - the following Attributes are exported:


An identity block exports the following:

Role Assignment

To enable metrics flow, perform role assignment on the identity created above. Monitoring reader(43d0d8ad-25c7-4714-9337-8ba259a9fe05) role is required .

Role assignment on the monitor created

data "azurerm_subscription" "primary" {}

data "azurerm_role_definition" "monitoring_reader" {
  name = "Monitoring Reader"
}

resource "azurerm_role_assignment" "example" {
  scope              = data.azurerm_subscription.primary.id
  role_definition_id = data.azurerm_role_definition.monitoring_reader.role_definition_id
  principal_id       = azurerm_datadog_monitor.example.identity[0].principal_id
}

Timeouts

The timeouts block allows you to specify timeouts for certain actions:

Import

Datadog Monitors can be imported using the resource id, e.g.

terraform import azurerm_datadog_monitor.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.Datadog/monitors/monitor1