Hi,
We are using this nrql { }
block and its query
attribute, belonging the nrql_alert_condition
resource:
And the query is for a module for use of multiple services/ New Relic APMs, so currently we have this.
nrql {
query = "SELECT filter(COUNT(*), WHERE request.uri='{var.path}' AND http.statusCode=200 FROM Transaction WHERE appName='${var.apm_name}'"
}
The 200
is an integer and valid for New Relic Java agents, however, for Node agents that also use this NRQL query
, the 200
must be represented as a string '200'
for whatever reason.
Is there a good way to get some ternary logic into that query
, or perhaps not try to do the ternary logic evaluation inside the NRQL string. We had checked in the past if the agent was Java by using our own variable lang
, so a check for var.lang === "java"
could be done.
I did try this, but it doesn’t appear to like it in the VSCode linting
nrql {
query = "SELECT filter(COUNT(*), WHERE request.uri='{var.path}' AND http.statusCode=${var.lang == "java" ? 200 : '200' })FROM Transaction WHERE appName='${var.apm_name}'"
}
Not sure if this should work or if there is a better option