newrelic / terraform-provider-newrelic

Terraform provider for New Relic
https://registry.terraform.io/providers/newrelic/newrelic/latest/docs
Mozilla Public License 2.0
200 stars 247 forks source link

newrelic_alert_channel fails to create alert channel gives up after 4 attempts #2085

Closed mike-davis-sada closed 1 year ago

mike-davis-sada commented 2 years ago

TF_LOG=TRACE< 2022-11-02T13:15:56.435-0700 [INFO] provider.terraform-provider-newrelic_v3.6.1: 2022/11/02 13:15:56 [DEBUG] newrelic API Response Details: ---[ RESPONSE ]-------------------------------------- HTTP/1.1 500 Internal Server Error Transfer-Encoding: chunked Cache-Control: no-cache Content-Security-Policy: frame-ancestors *.newrelic.com Content-Type: application/json Date: Wed, 02 Nov 2022 20:15:56 GMT Proxied-By: Service Gateway Server: nginx Status: 500 Internal Server Error X-Rack-Cache: invalidate, pass X-Request-Id: `` X-Ua-Compatible: IE=Edge,chrome=1

2b
{
 "error": {
  "title": "Internal Server Error"
 }
}
0

-----------------------------------------------------: timestamp=2022-11-02T13:15:56.435-0700
2022-11-02T13:15:57.438-0700 [INFO]  provider.terraform-provider-newrelic_v3.6.1: 2022/11/02 13:15:57 [DEBUG] newrelic API Request Details:
---[ REQUEST ]---------------------------------------
POST /v2/alerts_channels.json HTTP/1.1
Host: api.newrelic.com
User-Agent: HashiCorp Terraform/1.3.3 (+https://www.terraform.io) Terraform Plugin SDK/2.10.1 terraform-provider-newrelic/3.6.1
Content-Length: 144
Api-Key: `REDACTED`
Content-Type: application/json
Newrelic-Requesting-Services: terraform-provider-newrelic|newrelic-client-go
X-Account-Id: ``
Accept-Encoding: gzip

{
 "channel": {
  "name": "me@myemail.com",
  "type": "email",
  "configuration": {
   "recipients": "me@myemail.com",
   "include_json_attachment": "true"
  },
  "links": {}
 }
}
-----------------------------------------------------: timestamp=2022-11-02T13:15:57.437-0700
2022-11-02T13:15:57.629-0700 [INFO]  provider.terraform-provider-newrelic_v3.6.1: 2022/11/02 13:15:57 [DEBUG] newrelic API Response Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 500 Internal Server Error
Transfer-Encoding: chunked
Cache-Control: no-cache
Content-Security-Policy: frame-ancestors *.newrelic.com
Content-Type: application/json
Date: Wed, 02 Nov 2022 20:15:57 GMT
Proxied-By: Service Gateway
Server: nginx
Status: 500 Internal Server Error
X-Rack-Cache: invalidate, pass
X-Request-Id: ``
X-Ua-Compatible: IE=Edge,chrome=1

2b
{
 "error": {
  "title": "Internal Server Error"
 }
}
0

Terraform Version

Run terraform -v to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed. ❯ terraform -v Terraform v1.3.3 on darwin_arm64

Affected Resource(s)

Please list the resources as a list, for example:

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

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.


terraform {
# Require the latest 3.6.x+ version of the New Relic provider
required_providers {
newrelic = {
source  = "newrelic/newrelic"
version = "~> 3.6.1"
}
}
}

provider "newrelic" { account_id = XXX # Your New Relic account ID api_key = "NRAK-XXX" # Your New Relic user key region = "US" # US or EU (defaults to US) }

data "newrelic_entity" "foodme" { name = "FoodMe" # 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" }

NRQL alert condition

resource "newrelic_nrql_alert_condition" "average-duration" { policy_id = newrelic_alert_policy.alert_policy_name.id type = "static" name = "Average(Duration)" description = "Alert when transactions are taking too long" runbook_url = "https://www.example.com" enabled = true violation_time_limit_seconds = 3600

nrql { query = "SELECT average(duration) FROM Transaction where appName = '${data.newrelic_entity.foodme.name}'" // DEPRECATED evaluation_offset = 3 }

critical { operator = "above" threshold = 5.5 threshold_duration = 300 threshold_occurrences = "ALL" } }

Notification channel

resource "newrelic_alert_channel" "alert_notification_email" { name = "miked@sada.com" type = "email"

config { recipients = "miked@sada.com" include_json_attachment = "1" } }

Link the above notification channel to your policy

resource "newrelic_alert_policy_channel" "alert_policy_email" { policy_id = newrelic_alert_policy.alert_policy_name.id channel_ids = [ newrelic_alert_channel.alert_notification_email.id ] }

resource "newrelic_alert_policy" "alert_policy_name" { name = "Alert Policy - ${data.newrelic_entity.foodme.name}" }



### Actual Behavior
What actually happened?

### Expected Behavior
What should have happened?

### Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
1.  Following the instructions on https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/guides/getting_started
2. `terraform apply`

### Debug Output
Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

### Panic Output
If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the `crash.log`.

### Important Factoids
Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

### References
Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:
- GH-1234
hwilkalis-nr commented 2 years ago

We are looking into this but have.a couple of questions and requests for more information:

  1. In the original support ticket that was filed, the version was noted as 3.3.0, but this report has the version listed as 3.6.1. Did the error message change once you upgraded the provider?
  2. In checking the data from some of the failed requests against your account data, we found that some of the channel IDs listed in the request parameters do not exist in the account. Have you been deleting some of the channels as you test? Since the error source is pointing to a data error with the channel ID, this may help us to narrow down the cause.
  3. Is the error data you've provided above the complete contents of the log file? If not, please provide a complete copy as described in the Issue template:

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

NSSPKrishna commented 1 year ago

Hi, we haven’t heard back from you in a long time so we will close the ticket. If you feel this is still a valid request or bug, feel free to create a new issue.