terraform-provider-newrelic icon indicating copy to clipboard operation
terraform-provider-newrelic copied to clipboard

Creating a newrelic_alert_channel returns 500

Open ivanaguilario opened this issue 2 years ago • 1 comments

Terraform Version

Terraform v1.2.7 Provider v2.49.1

Affected Resource(s)

  • newrelic_alert_channel

Terraform Configuration

provider "newrelic" {
  account_id = "<redacted>"
  api_key = "<redacted>"
  region = "US"
}

resource "newrelic_alert_channel" "slack_cluster_alerts" {
  name = "k8s-i0-alerts"
  type = "slack"

  config {
    url = "https://<redacted>.slack.com"
    channel = "k8s-i0-alerts"
  }
}

Actual Behavior

API returns 500 response. Provider returns error: POST https://api.newrelic.com/v2/alerts_channels.json giving up after 4 attempt(s)

Expected Behavior

API should return success status code and create resource.

Steps to Reproduce

  1. terraform apply

Debug Output

-----------------------------------------------------: timestamp=2022-08-18T00:09:45.678+0200
2022-08-18T00:09:49.682+0200 [INFO]  provider.terraform-provider-newrelic_v2.49.1: 2022/08/18 00:09:49 [DEBUG] newrelic API Request Details:
---[ REQUEST ]---------------------------------------
POST /v2/alerts_channels.json HTTP/1.1
Host: api.newrelic.com
User-Agent: HashiCorp Terraform/1.2.7 (+https://www.terraform.io) Terraform Plugin SDK/2.9.0 terraform-provider-newrelic/2.49.1
Content-Length: 145
Api-Key: <redacted>
Content-Type: application/json
Newrelic-Requesting-Services: terraform-provider-newrelic|newrelic-client-go
X-Account-Id: <redacted>
Accept-Encoding: gzip

{
 "channel": {
  "name": "k8s-i0-alerts",
  "type": "slack",
  "configuration": {
   "url": "https://<redacted>.slack.com",
   "channel": "k8s-i0-alerts"
  },
  "links": {}
 }
}
-----------------------------------------------------: timestamp=2022-08-18T00:09:49.682+0200
2022-08-18T00:09:49.912+0200 [INFO]  provider.terraform-provider-newrelic_v2.49.1: 2022/08/18 00:09:49 [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, 17 Aug 2022 22:09:52 GMT
Proxied-By: Service Gateway
Server: nginx
Status: 500 Internal Server Error
X-Rack-Cache: invalidate, pass
X-Request-Id: 332d3d08111c815b4addec230797969a
X-Runtime: 0.078130
X-Ua-Compatible: IE=Edge,chrome=1

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

ivanaguilario avatar Aug 17 '22 22:08 ivanaguilario

I've tested it with type email and it's returning the same error:

-----------------------------------------------------: timestamp=2022-08-18T00:33:09.168+0200
2022-08-18T00:33:13.169+0200 [INFO]  provider.terraform-provider-newrelic_v2.49.1: 2022/08/18 00:33:13 [DEBUG] newrelic API Request Details:
---[ REQUEST ]---------------------------------------
POST /v2/alerts_channels.json HTTP/1.1
Host: api.newrelic.com
User-Agent: HashiCorp Terraform/1.2.7 (+https://www.terraform.io) Terraform Plugin SDK/2.9.0 terraform-provider-newrelic/2.49.1
Content-Length: 152
Api-Key: <redacted>
Content-Type: application/json
Newrelic-Requesting-Services: terraform-provider-newrelic|newrelic-client-go
X-Account-Id: 3523578
Accept-Encoding: gzip

{
 "channel": {
  "name": "k8s-i0-alerts-email",
  "type": "email",
  "configuration": {
   "recipients": "<redacted>",
   "include_json_attachment": "true"
  },
  "links": {}
 }
}
-----------------------------------------------------: timestamp=2022-08-18T00:33:13.169+0200
2022-08-18T00:33:13.374+0200 [INFO]  provider.terraform-provider-newrelic_v2.49.1: 2022/08/18 00:33:13 [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, 17 Aug 2022 22:33:16 GMT
Proxied-By: Service Gateway
Server: nginx
Status: 500 Internal Server Error
X-Rack-Cache: invalidate, pass
X-Request-Id: 5bf84dcc828916c481267760fd2661d2
X-Runtime: 0.060952
X-Ua-Compatible: IE=Edge,chrome=1

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


-----------------------------------------------------: timestamp=2022-08-18T00:33:13.374+0200

ivanaguilario avatar Aug 17 '22 22:08 ivanaguilario

@ivanaguilario We've had some intermittent issues in the Alerts API. Can you confirm that you're still seeing this problem?

mbazhlekova avatar Aug 25 '22 15:08 mbazhlekova

@ivanaguilario Is the account you are using here a new account that does not have any channels set up yet? We are in the process of migrating notifications to a new system, and accounts that are not configured with the old system need to be set up in the new system instead. More details here: https://discuss.newrelic.com/t/plan-to-upgrade-alert-notification-channels-to-workflows-and-destinations/188205

Terraform support for the new "Destinations" and "Channels" is available now: https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/notification_destination https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/notification_channel

We do not have Terraform support for Workflows yet, but this is currently in progress and will be made available when it is finished.

If this is not a new account, let me know and I will see if I can find anything else on our side.

emetcalf9 avatar Aug 25 '22 18:08 emetcalf9

Hi @ivanaguilario,
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.

NSSPKrishna avatar Sep 20 '22 10:09 NSSPKrishna