使用Terraform推送New Relic告警遇INVALID_PARAMETER错误求助
解决New Relic Terraform PagerDuty通知渠道创建错误
错误根源
你遇到的INVALID_PARAMETER和Entities' types do not match错误,主要由两个核心问题导致:
Product参数拼写错误
代码中product = "IINT"是无效值,New Relic的newrelic_notification_channel资源里,PagerDuty集成对应的有效值为"NEW_RELIC"(适配New Relic One告警工作流)或"INFRA"(适配基础设施告警),需根据你的告警场景选择。Destination ID类型不匹配
destination_id必须对应一个已创建的PagerDuty类型Destination。如果该ID指向的是Email、Slack等其他类型的Destination,就会触发实体类型不匹配的错误。
修正代码
resource "newrelic_notification_channel" "PD_Channel" { name = "pagerduty-channel-production" type = "PAGERDUTY_SERVICE_INTEGRATION" destination_id = "8dasd-asdad-adsadsa-xxxx" # 确认此ID属于PagerDuty类型Destination product = "NEW_RELIC" # 修正拼写,根据实际场景替换为INFRA或其他有效值 property { key = "summary" value = "{{ annotations.title.[0] }}" } property { key = "customDetails" value = <<-EOT { "id":{{json issueId}}, "IssueURL":{{json issuePageUrl}}, "NewRelic priority":{{json priority}}, "Total Incidents":{{json totalIncidents}}, "Impacted Entities":"{{#each entitiesData.names}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}", "Runbook":"{{#each accumulations.runbookUrl}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}", "Description":"{{#each annotations.description}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}", "isCorrelated":{{json isCorrelated}}, "Alert Policy Names":"{{#each accumulations.policyName}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}", "Alert Condition Names":"{{#each accumulations.conditionName}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}", "Workflow Name":{{json workflowName}} } EOT } }
验证步骤
- 核对
destination_id:确保它是通过New Relic UI或newrelic_notification_destinationTerraform资源创建的PagerDuty Destination。 - 确认
product参数:匹配你的告警产品类型,比如用"INFRA"对应基础设施告警。 - 执行
terraform plan检查参数合法性,再运行terraform apply完成创建。
内容的提问来源于stack exchange,提问作者Linux Geek
相关产品推荐
相关产品推荐

