Terraform-provider-newrelic: newrelic_alert_condition.entities cannot be populated by data.newrelic_entity.guid

Created on 6 Jul 2020  路  5Comments  路  Source: newrelic/terraform-provider-newrelic

Terraform Version

Terraform v0.12.28
Provider version 2.1.2

Affected Resource(s)

  • newrelic_alert_condition
  • data.newrelic_entity

Terraform Configuration Files

data "newrelic_entity" "app" {
  name = var.newrelic-app-name
  domain = "APM"
  type = "APPLICATION"
}

output "newrelic-app-id" {
  value = data.newrelic_entity.app.guid
}

resource "newrelic_alert_condition" "apdex-low" {
  ...
  entities        = [module.alerts.newrelic-app-id]
  ...
}

Expected Behavior

Since the newrelic_application data source is deprecated, and the docs say that newrelic_entity is the replacement, I would expect to be able to create an alert condition based off the output of the newrelic_entity data source.

Actual Behavior

Where data.newrelic_application.id is a number, data.newrelic_entity.guid is a string. That causes the following error:

Error: Incorrect attribute value type

  on newrelic.tf line 7, in resource "newrelic_alert_condition" "apdex-low":
   7:   entities        = [module.alerts.newrelic-app-id]
    |----------------
    | module.alerts.newrelic-app-id is "MTU2[...]"

Inappropriate value for attribute "entities": a number is required.

waiting-response

All 5 comments

Hi @apottere!

The guidance from the Alerts team here at New Relic is to make use of NRQL alert conditions instead of classic APM conditions moving forward. The (string-typed) ID space for entities is distinct from the legacy (int-typed) ID space used by applications, so you won't be able to target applications via entity GUIDs using the newrelic_application data source. The term entity has been overloaded here so I can appreciate how this has caused some confusion.

The entity_guid attribute in the Transaction event type can be used in your NRQL query to target a specific application that has been referenced by the newrelic_entity data source. Here's an example:

SELECT apdex(duration) from Transaction where entityGuid = 'MjUwODI1OXxBUE18QVBQTElDQVRJT058MjA0MjYxMzY4'

Please give it a try and let us know if you have any other questions.

We can certainly make those changes, but it would be good to deprecate newrelic_alert_condition as well if people should be moving away from it.

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs.

Good point @apottere, I've put up https://github.com/newrelic/terraform-provider-newrelic/pull/910 to deprecate the newrelic_alert_condition resource. How is the migration to the newrelic_nrql_alert_condition going?

We haven't tried migrating over yet, right now we're pinning the provider version and using newrelic_alert_condition with the deprecated newrelic_entity. I don't suspect we'll have any issues switching over to NRQL alerts when we get the bandwidth though. Thanks for creating #910!

Was this page helpful?
0 / 5 - 0 ratings