terraform-provider-newrelic: TF apply fails on `newrelic_nrql_alert_condition`

Terraform Version

terraform {
  required_version = "1.4.5"
  required_providers {
    newrelic = {
      source  = "newrelic/newrelic"
      version = "3.20.2"
    }
  }
}

Affected Resource(s)

  • newrelic_nrql_alert_condition

Terraform Configuration

# Too much information to redact. We have thousands of lines of terraform. Here's an example:
# NEW_RELIC_ACCOUNT_ID is set as an environment variable

data "newrelic_entity" "ecs_app" {
  name = var.new_relic_alerts_app_name  # Must be an exact match to your application name in New Relic
  domain = "APM" # or BROWSER, INFRA, MOBILE, SYNTH, depending on your entity's domain
  type = "APPLICATION"
}

resource "newrelic_alert_policy" "nr_alerts_policy" {
  name = var.new_relic_alerts_app_name
  incident_preference = "PER_POLICY" # PER_POLICY is default
}

resource "newrelic_nrql_alert_condition" "api_error_percentage" {
  policy_id = data.newrelic_alert_policy.nr_alerts_policy.id
  type = "static"
  name = "${var.new_relic_alerts_app_name} - Error Percentage"
  enabled = true
  violation_time_limit_seconds = 259200

  nrql {
    query = "SELECT count(apm.service.error.count) / count(apm.service.transaction.duration) AS 'All errors' FROM Metric WHERE entity.guid = '${data.newrelic_entity.ecs_app.guid}' FACET `host`"
  }

  warning {
    operator = "above"
    threshold = 3
    threshold_duration = 300
    threshold_occurrences = "all"
  }
  fill_option = "none"
  aggregation_window = 60
  aggregation_method = "event_flow"
  aggregation_delay = 120
}

This was functioning ~7 hours ago as of this writing. Nothing has changed in our terraform, and no one has made any manual changes to our alerting policies, conditions, or APM entities.

Actual Behavior

╷
│ Error: Unknown Error
│ 
│   with module.redacted.module.ecs_task.module.new_relic_api_service_alerts[0].newrelic_nrql_alert_condition.api_error_percentage,
│   on ../terraform-shared-modules/new-relic-api-alerts/main.tf line 119, in resource "newrelic_nrql_alert_condition" "api_error_percentage":
│  119: resource "newrelic_nrql_alert_condition" "api_error_percentage" {
│ 
╵
Error: Process completed with exit code 1.

Expected Behavior

Nothing at all. No errors. The resources were created in the past, and have been left alone for weeks or months.

Steps to Reproduce

  1. terraform apply or terraform plan

Debug Output

  • See actual behavior.

Panic Output

  • See actual behavior.

Important Factoids

  • This was working hours ago with provider version 3.14.0. We tried version 3.20.2 to see if that would fix, but it didn’t.
  • We first noticed these errors happening around 3 hours ago as of this writing
  • We also tried deleting specific conditions, or entire policies, and we would see them recreated by terraform (so our license / User API key is valid) but still would see the errors.
  • This happens on both apply and plan

References

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 14
  • Comments: 24 (9 by maintainers)

Most upvoted comments

Thank you @piekstra . Closing the issue as it is resolved.

Resolved for our pipelines also.

2023-04-27T02:11:19.5429050Z 2023-04-27T02:11:18.861Z [ERROR] vertex "module.redacted.module.ecs_task.module.new_relic_api_service_alerts[0].newrelic_nrql_alert_condition.api_error_percentage" error: Unknown Error
2023-04-27T02:11:19.5429729Z 2023-04-27T02:11:18.861Z [ERROR] vertex "module.redacted.module.ecs_task.module.new_relic_api_service_alerts[0].newrelic_nrql_alert_condition.api_error_percentage" error: Unknown Error
2023-04-27T02:11:19.5430472Z 2023-04-27T02:11:18.861Z [ERROR] vertex "module.redacted.module.ecs_task.module.new_relic_api_service_alerts.newrelic_nrql_alert_condition.api_error_percentage (expand)" error: Unknown Error
2023-04-27T02:11:19.5431036Z 2023-04-27T02:11:18.861Z [INFO]  provider.terraform-provider-newrelic_v3.14.0: 2023/04/27 02:11:18 [DEBUG] newrelic API Response Details:
2023-04-27T02:11:19.5431420Z ---[ RESPONSE ]--------------------------------------
2023-04-27T02:11:19.5431578Z HTTP/1.1 200 OK
2023-04-27T02:11:19.5431799Z Transfer-Encoding: chunked
2023-04-27T02:11:19.5432095Z Cache-Control: max-age=0, private, must-revalidate
2023-04-27T02:11:19.5432447Z Content-Security-Policy: frame-ancestors *.newrelic.com
2023-04-27T02:11:19.5432728Z Content-Type: application/json; charset=utf-8
2023-04-27T02:11:19.5432917Z Date: Thu, 27 Apr 2023 02:11:18 GMT
2023-04-27T02:11:19.5433130Z Proxied-By: Service Gateway
2023-04-27T02:11:19.5433345Z Served-By: nerd-graph
2023-04-27T02:11:19.5433487Z Server: Cowboy
2023-04-27T02:11:19.5433859Z Strict-Transport-Security: max-age=31536000; includeSubDomains
2023-04-27T02:11:19.5433939Z 
2023-04-27T02:11:19.5434062Z 100
2023-04-27T02:11:19.5434196Z {
2023-04-27T02:11:19.5434326Z  "data": {
2023-04-27T02:11:19.5434473Z   "actor": {
2023-04-27T02:11:19.5434612Z    "account": {
2023-04-27T02:11:19.5434759Z     "alerts": {
2023-04-27T02:11:19.5434927Z      "nrqlCondition": null
2023-04-27T02:11:19.5435050Z     }
2023-04-27T02:11:19.5435187Z    }
2023-04-27T02:11:19.5435310Z   }
2023-04-27T02:11:19.5435446Z  },
2023-04-27T02:11:19.5435755Z  "errors": [
2023-04-27T02:11:19.5435929Z   {
2023-04-27T02:11:19.5436077Z    "extensions": {
2023-04-27T02:11:19.5436255Z     "code": "SERVER_ERROR",
2023-04-27T02:11:19.5436577Z     "errorClass": "SERVER_ERROR"
2023-04-27T02:11:19.5436726Z    },
2023-04-27T02:11:19.5436870Z    "locations": [
2023-04-27T02:11:19.5436992Z     {
2023-04-27T02:11:19.5437262Z      "column": 7,
2023-04-27T02:11:19.5437486Z      "line": 6
2023-04-27T02:11:19.5437622Z     }
2023-04-27T02:11:19.5437743Z    ],
2023-04-27T02:11:19.5438036Z    "message": "Unknown Error",
2023-04-27T02:11:19.5438291Z    "path": [
2023-04-27T02:11:19.5438438Z     "actor",
2023-04-27T02:11:19.5438574Z     "account",
2023-04-27T02:11:19.5438839Z     "alerts",
2023-04-27T02:11:19.5439008Z     "nrqlCondition"
2023-04-27T02:11:19.5439131Z    ]
2023-04-27T02:11:19.5439271Z   }
2023-04-27T02:11:19.5439393Z  ]
2023-04-27T02:11:19.5439651Z }
2023-04-27T02:11:19.5439786Z 0
2023-04-27T02:11:19.5439794Z 
2023-04-27T02:11:19.5439801Z 
2023-04-27T02:11:19.5440275Z -----------------------------------------------------: timestamp=2023-04-27T02:11:18.860Z
2023-04-27T02:11:19.5441953Z 2023-04-27T02:11:18.861Z [ERROR] provider.terraform-provider-newrelic_v3.14.0: Response contains error diagnostic: tf_rpc=ReadResource @module=sdk.proto diagnostic_detail= diagnostic_severity=ERROR tf_provider_addr=provider tf_resource_type=newrelic_nrql_alert_condition @caller=/home/runner/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.12.0/tfprotov5/internal/diag/diagnostics.go:56 diagnostic_summary="Unknown Error" tf_proto_version=5.3 tf_req_id=10ed476d-ca6a-9aa0-7c22-f0a592932b57 timestamp=2023-04-27T02:11:18.860Z

@RavitejaSurampudi all good from my side. Thank you very much!

@Lizzam / @notshof Could you try now and check if you are facing the issue still ?

Thanks it has been fixed.

That’s fixed it for our pipelines, thank you!

@Lizzam / @notshof Could you try now and check if you are facing the issue still ?

Thank you @piekstra . we will analyse and update you ASAP.

@piekstra Thank you for bringing this to our notice. we are looking into this now.

We have the same issue here. It was working properly earlier today.