• /
  • Log in

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

Metric data is more complex than other types of data. There are specific tips for querying it well. We have two types of metric data, each with their own query guidelines:

For more on understanding these data types, see Metric data types.

Functions

In this section we explain NRQL functions, both aggregator functions and non-aggregator functions.

Aggregator functions

You can use aggregator functions to filter and aggregate data. Some tips for using these:

Examples:

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

Non-aggregator functions

Use non-aggregator functions for non-numerical data in NRQL queries.

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:

Create issueEdit page
Copyright © 2021 New Relic Inc.