terraform-provider-newrelic: newrelic_nrql_drop_rule not getting created via terraform
Hello Team,
I’m having an issue in where i’m unable to create a newrelic drop rule via terraform. Initially i was working to create a module which takes in a list of objects; where each object is a drop filter rule (contains description , action, account id, and query), and simple creates and applies the drop rule. I created a simple drop rule resource and removed my module code (to eliminate issues), However on the apply is where i’am getting an error. The error is reporting the drop rule is not getting returned and to validate the action value or NRQL. The NRQL is validd, and action type is also valid. We attempted to use charles to debug http traffic, and we can even see the nerdgraph result of success. It looks like there appears to be a bug.
Error
[31m╷[0m[0m [31m│[0m [0m[1m[31mError: [0m[0m[1merr: drop rule create result wasn't returned. Validate the action value or NRQL query.[0m [31m│[0m [0m [31m│[0m [0m[0m with module.newrelic-drop-rule.newrelic_nrql_drop_rule.drop_filter_rule["0"], [31m│[0m [0m on newrelic-drop-rule/1_nr_drop_rule.tf line 3, in resource "newrelic_nrql_drop_rule" "drop_filter_rule": [31m│[0m [0m 3: resource "newrelic_nrql_drop_rule" "drop_filter_rule" [4m{[0m[0m [31m│[0m [0m [31m╵[0m[0m
Provider config
`terraform {
required_version = “>= 0.15.0”
required_providers { google-beta = “>= 3.66.1” graphql = { source = “sullivtr/graphql” version = “2.0.0-rc” } newrelic = { source = “newrelic/newrelic” version = “>= 2.49.1” } } } `
source code ` resource “newrelic_nrql_drop_rule” “drop_filter_rule” { description = “dropping value not found logs” action = “drop_data” nrql = “SELECT * FROM Log, LogExtendedRecord WHERE message LIKE ‘%value not found%’ AND newrelic.logs.customEventType IS NULL” }
`
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.
Affected Resource(s)
Please list the resources as a list, for example:
newrelic_alert_policynewrelic_alert_channel
If this issue appears to affect multiple resources, it may be an issue with Terraform’s core, so please mention this.
Actual Behavior
No drop rule resource getting created
Expected Behavior
drop rule resource should e getting created
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
terraform apply
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (7 by maintainers)
@danielgblanco Can you try adding a
rin front of the query, this is required for RLIKE: https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions/example:
FROM Log SELECT * WHERE service.name = 'my-service' AND message RLIKE r'.*([a-zA-Z0-9_+&*-]+(?:\\.[a-zA-Z0-9_+&*-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}).*'@NSSPKrishna , could you please take a look and validate
Never mind, found the original issue. The query above
Would not work in the NRQL console (it would not match anything). But if we remove the double backslash it would.
There may be some escaping/unescaping that happens when applying Terraform values that is affecting this so the behaviour is not the same between NRQL console and Terraform provider.
After adding ‘r’ in front of the query, our problem was resolved. However, the same query is not working with query builder and does not return any result. We removed ‘r’ to test it with the query builder. Thanks for the help!