Creating New Relic Infrastructure Alerts using Terraform - Alerts don't trigger

Hello,

I am having problems getting an Infra Alert Condition created using Terraform to trigger alerts. This is the code for creating the alerts with Terraform:

data “newrelic_alert_policy” “new_relic_policy_gcp_p4” {
name = “GCP P4”
}

resource “newrelic_infra_alert_condition” “disk_alert” {
policy_id = data.newrelic_alert_policy.new_relic_policy_gcp_p4.id
name = “GCP High Disk Utilisation 2”
type = “infra_metric”
event = “GcpCloudSqlSample”
select = “database.disk.Utilization”
comparison = “above”

critical {
duration = 5
value = 0.11
time_function = “all”
}
}

The alerts condition is created OK - but it does not trigger alerts. However, when the same is created manually on the console, alerts are trigger.

The target resource am alerting on is a GCP CloudSQL instance.

Is there something I am missing from the configuration? Unfortunately the attributes of this resources is not very well documented.

Hi @victor.katte

Could you try go into the UI and resave the same condition created via Terraform?

We’ve seen rare cases where conditions created via the API (or terraform in this case), have not synced to the Alerts DB upon creation. Usually resaving the condition re-syncs it to the DB and ensures the condition will trigger.

Thanks @RyanVeitch

I have re-saved it, waited about 15 minutes and it is still not triggering the alerts.

Hi @victor.katte

I see that you were trying to create an Infrastructure Disk metric alert condition on a Cloud integration metric, which isn’t possible – Infrastructure Disk metric conditions are for hosts which have the Infrastructure agent installed on them. Hopefully when you re-created the alert condition using the UI, you created a Cloud Integration alert condition type.

I’d be happy to look into it and see what’s going wrong with this alert condition. Will you please provide a link to the alert condition here? This will allow me to dig in and troubleshoot.