• /
  • Log in
  • Free account
Docs

NRQL syntax, clauses, and functions

NRQL is a query language you can use to query the New Relic database. This document explains NRQL syntax, clauses, components, and functions.

Syntax

This document is a reference for the functions and clauses used in a NRQL query. Other resources for understanding NRQL:

Query components

Every NRQL query will begin with a SELECT statement or a FROM clause. All other clauses are optional. The clause definitions below also contain example NRQL queries.

Required clauses

Optional clauses

Query metric data

There are several ways to query metric data using NRQL:

For more on understanding metrics in New Relic, see Metric data types.

Aggregator functions

Use aggregator functions to filter and aggregate data in a NRQL query. Some helpful information about using aggregator functions:

Here are the available aggregator functions. The definitions below contain example NRQL queries.

Examples:

SELECT histogram(duration, 10, 20) FROM PageView SINCE 1 week ago

Examples:

SELECT max(getField(mySummary, count)) from Metric
SELECT sum(mySummary) from Metric where getField(mySummary, count) > 10

Type conversion

NRQL does not support "coercion." This means that a float stored as a string is treated as a string and cannot be operated on by functions expecting float values.

You can convert a string with a numeric value or a boolean with a string value to their numeric and boolean types with these functions:

  • Use the numeric() function to convert a number with a string format to a numeric function. The function can be built into a query that uses math functions on query results or NRQL aggregator functions, such as average().
  • Use the boolean() function to convert a string value of "true" or "false" to the corresponding boolean value.

For more help

If you need more help, check out these support and learning resources:

Docs
Create issueEdit page
Copyright © 2021 New Relic Inc.