terraform-provider-newrelic: newrelic_nrql_alert_condition throws: Cannot query field "slideBy" on type "AlertsNrqlConditionSignal"

Terraform Version

Terraform v1.2.9
+ provider registry.terraform.io/newrelic/newrelic v3.8.0

Affected Resource(s)

Please list the resources as a list, for example:

  • newrelic_nrql_alert_condition

Terraform Configuration

Please include your provider configuration (sensitive details redacted) as well as the configuration of the resources and/or data sources related to the bug report.

provider "newrelic" {
  region        = "US"
  admin_api_key = var.admin_api_key
  api_key       = var.personal_api_key
  account_id    = "..."
}

resource "newrelic_nrql_alert_condition" "condition" {
  name                         = "name"
  violation_time_limit_seconds = 86400
  aggregation_method           = "event_flow"
  aggregation_window = 900
  aggregation_delay  = 3

  nrql {
    query = "SELECT count(*) FROM SyntheticCheck WHERE result = 'FAILED' AND monitorName = '${var.monitor_name}'"
  }

  policy_id = var.policy_id

  critical {
    operator  = "above_or_equals"
    threshold = 1
    threshold_duration    = 900 * var.strikes
    threshold_occurrences = "all"
  }
}

Actual Behavior

After upgrading from provider v2 to v3 newrelic_nrql_alert_condition was working fine. It stopped working when we created first new script monitor via the v3 provider.

Error: Cannot query field "slideBy" on type "AlertsNrqlConditionSignal".
with newrelic_nrql_alert_condition.condition, on modules/nrql_synthetic_monitor_alert_condition/main.tf line 15, in resource "newrelic_nrql_alert_condition" "condition":
  15: resource "newrelic_nrql_alert_condition" "condition" {

Expected Behavior

newrelic_nrql_alert_condition should work as it was before.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform plan

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 16
  • Comments: 17

Most upvoted comments

I’m now running into this issue when running terraform plan without making any changes to my terraform that previously worked.

I’m using 3.4.2 and my last successful plan/apply was at Dec 2 11:11am MST. Upgrading to 3.4.4 does not seem to fix the issue.

I think NewRelic api may have some backwards incompatible changes that have broken this tf module.

Looks good on my side. I managed to execute terraform plan and terraform apply commands. I’m using NewRelic Terraform provider 3.8.0. Thanks a lot for quick help

Same here. TF 1.3.x provider 2.x / 3.x. major blocker for us

Looks good over here. Thank you!

Sure, will try. Will let you know in few minutes

Working config (terraform apply succeeds):

main.tf:

terraform {
  required_providers {
    newrelic = {
      source = "newrelic/newrelic"
      version = "2.35.1"
    }
  }
}

variable "api_key" {
}
variable "account_id" {
}
variable "monitor_name" {
}
variable "policy_id" {
}

provider "newrelic" {
  region        = "US"
  api_key       = var.api_key
  account_id    = var.account_id
}

resource "newrelic_nrql_alert_condition" "condition" {
  name                         = "name"

  nrql {
    query = "SELECT count(*) FROM SyntheticCheck WHERE result = 'FAILED' AND monitorName = '${var.monitor_name}'"
  }

  policy_id = var.policy_id
  value_function = "SINGLE_VALUE"

  critical {
    operator  = "above"
    threshold = 1
    threshold_duration = 900
    threshold_occurrences = "all"
  }
}

Broken config:

main.tf:

terraform {
  required_providers {
    newrelic = {
      source = "newrelic/newrelic"
      version = "2.36.0"
    }
  }
}

variable "api_key" {
}
variable "account_id" {
}
variable "monitor_name" {
}
variable "policy_id" {
}

provider "newrelic" {
  region        = "US"
  api_key       = var.api_key
  account_id    = var.account_id
}

resource "newrelic_nrql_alert_condition" "condition" {
  name                         = "name"

  nrql {
    query = "SELECT count(*) FROM SyntheticCheck WHERE result = 'FAILED' AND monitorName = '${var.monitor_name}'"
  }

  policy_id = var.policy_id
  value_function = "SINGLE_VALUE"

  critical {
    operator  = "above"
    threshold = 1
    threshold_duration = 900
    threshold_occurrences = "all"
  }
}

Set var.api_key, var.account_id, var.monitor_name, and var.policy_id accordingly.

Terraform version:

$ terraform version
Terraform v1.3.4
on darwin_amd64

EDIT: Add TF version