Archive · DevOps

New Relic: NRQL Dashboards and Alerts

Query your telemetry with NRQL and turn a query into an alert condition.

1 min read

  • New Relic One
  • NRQL

NRQL is New Relic’s SQL-like query language. Try these in the query builder:

SELECT average(cpuPercent) FROM SystemSample FACET hostname SINCE 1 hour ago TIMESERIES

SELECT percentile(duration, 95) FROM Transaction WHERE appName = 'shop-api' SINCE 1 day ago TIMESERIES

SELECT count(*) FROM TransactionError WHERE appName = 'shop-api' FACET error.message SINCE 1 hour ago

Save charts to a dashboard: one row for traffic and latency, one for errors, one for hosts.

Create an alert condition from a query:

  1. Alerts, Alert conditions, NRQL.
  2. Query: SELECT percentage(count(*), WHERE error IS true) FROM Transaction WHERE appName = 'shop-api'.
  3. Threshold: above 5 percent for at least 5 minutes.
  4. Attach the condition to a policy with a workflow that notifies Slack, email or PagerDuty.

Alert on symptoms users feel (errors, latency) before causes (CPU). Add a muting rule for planned maintenance so deployments do not page anyone.