Skip to content
Latchkey

New Relic NRQL syntax error in CI

New Relic returns an "NRQL Syntax Error" when a query run via NerdGraph or the CLI is malformed: a missing FROM, an unknown function, or a stray token. The response names the position it could not parse.

What this error means

A NerdGraph nrql query or a CLI deployment/SLI check returns "NRQL Syntax Error" with the offending position, and the step fails.

New Relic
NRQL Syntax Error: Error at line 1 position 28, unexpected 'WERE'
SELECT count(*) FROM Transaction WERE appName = 'web'

Common causes

A typo or missing clause in the NRQL

A misspelled keyword (WERE for WHERE), a missing FROM, or an unclosed string makes the query unparseable.

Unescaped interpolation in the CI step

A shell or YAML variable injected into the query without proper quoting produces invalid NRQL at runtime.

How to fix it

Fix the NRQL at the reported position

  1. Read the line and position in the syntax error.
  2. Correct the keyword, clause, or quoting at that spot.
  3. Re-run the query to confirm it parses.
Terminal
newrelic nerdgraph query \
  "{ actor { account(id: $ACCT) { nrql(query: \"SELECT count(*) FROM Transaction WHERE appName = 'web'\") { results } } } }"

Quote interpolated values safely

Wrap injected values in proper quotes so the assembled NRQL stays valid regardless of the value.

How to prevent it

  • Validate NRQL queries before wiring them into CI gates.
  • Quote interpolated variables so the query stays well-formed.
  • Keep complex queries in files rather than inline shell strings.

Frequently asked questions

What causes "New Relic "NRQL Syntax Error""?
A misspelled keyword (WERE for WHERE), a missing FROM, or an unclosed string makes the query unparseable.
How do I fix New Relic "NRQL Syntax Error"?
Fix the NRQL at the reported position

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card