---
title: Get started with NRQL: The language of data
source: https://docs.newrelic.com/docs/nrql/get-started/introduction-nrql-new-relics-query-language
---

New Relic Query Language (NRQL) is a SQL-like language for querying your New Relic data. The same query language that powers New Relic's built-in charts and dashboards is available to you, so you can build the views and alerts your team needs.

Here's a video to help introduce you to using NRQL by showing you how to find a query from a [dashboard](https://docs.newrelic.com/docs/query-your-data/explore-query-data/dashboards/introduction-dashboards) and modify it in the [query builder](https://docs.newrelic.com/docs/query-your-data/explore-query-data/query-builder/introduction-query-builder). For more detailed information on querying, including a listing of clauses, functions, and example queries, see our [NRQL reference](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions).

[Video](https://www.youtube.com/embed/ad6hZPHAsME)

## What you can do with NRQL [#nrql-overview]

Use NRQL to:

-   Build charts that show transaction throughput, error rates, or latency over time
-   Answer a specific question for the purpose of troubleshooting or business analysis
-   Investigate a performance issue by querying the specific events and attributes involved
-   Set up [NRQL-based alerts](https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/alert-conditions/create-nrql-alert-conditions) that fire when a metric crosses a threshold
-   Make API queries for your New Relic data for example, using our [NerdGraph](https://docs.newrelic.com/docs/apis/graphql-api/tutorials/nerdgraph-graphiql-nrql-tutorial) API.

NRQL works for both basic queries (fetching raw rows of event data) and calculated results, such as funnels based on how users interact with your site or application.

> #### 💡 TIP
>
> New Relic uses NRQL internally to power the charts and dashboards in the New Relic platform. That same query language is available to you.

## Queryable data types [#what-you-can-query]

NRQL lets you query nearly every type of our telemetry data, including:

-   [Event data](https://docs.newrelic.com/docs/using-new-relic/data/understand-data/new-relic-data-types#event-data) from all New Relic products. Examples include:
    -   [APM events](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/apm-default-events-insights), like `Transaction`
    -   [Browser monitoring events](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/browser-default-events-insights), like `PageView`
    -   [Mobile monitoring events](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/mobile-default-events-insights), like `Mobile`
    -   [Infrastructure events](https://docs.newrelic.com/docs/infrastructure/manage-your-data/data-instrumentation/default-infrastructure-events), like `ProcessSample`
    -   [Synthetic events](https://docs.newrelic.com/docs/insights/insights-data-sources/default-data/synthetics-default-events-insights), like `SyntheticCheck`
    -   Custom events, like those reported by the [Event API](https://docs.newrelic.com/docs/insights/insights-data-sources/custom-data/introduction-event-api)
-   The [`Metric` data type](https://docs.newrelic.com/docs/data-apis/understand-data/new-relic-data-types/#dimensional-metrics) (metrics reported by the Metric API and data sources that use that API)
-   The [`Span` data type](https://docs.newrelic.com/docs/using-new-relic/data/understand-data/new-relic-data-types#trace-data) (distributed tracing data)
-   The [`Log` data type](https://docs.newrelic.com/docs/using-new-relic/data/understand-data/new-relic-data-types#log-data) (data from our log management capabilities)

> #### 💡 TIP
>
> Some data, like relationships between monitored entities, is not available via NRQL but is available using our [NerdGraph API](https://docs.newrelic.com/docs/apis/nerdgraph/get-started/introduction-new-relic-nerdgraph).

## Where to use NRQL [#where]

NRQL is available across the platform:

### The query builder

![A screenshot of a NRQL query chart](https://docs.newrelic.com/images/queries-nrql_screenshot-crop_view-query-for-chart.webp "new-relic-view-chart-nrql-query.png")

Access the query builder through the Query your data drawer at the bottom of any New Relic page to run queries and create custom charts.

You can run an NRQL query in the [query builder](https://docs.newrelic.com/docs/chart-builder/use-chart-builder/get-started/introduction-chart-builder) within [the platform](https://docs.newrelic.com/docs/new-relic-one/use-new-relic-one/get-started/introduction-new-relic-one). This NRQL query shows a count of [distributed tracing](https://docs.newrelic.com/docs/understand-dependencies/distributed-tracing/get-started/introduction-distributed-tracing) spans faceted by their entity names.

### NRQL-based alerts

[NRQL-based alerts](https://docs.newrelic.com/docs/alerts-applied-intelligence/new-relic-alerts/alert-conditions/create-nrql-alert-conditions/) are the primary alert type in New Relic. To create one, go to **[one.newrelic.com > All capabilities](https://one.newrelic.com/all-capabilities) > Alerts > Alert conditions (Policies) > (select a policy) > Add a condition**, click **NRQL**, and then **Next, define thresholds**.

### NerdGraph API

![A screenshot of the Nerdgraph API](https://docs.newrelic.com/images/apis-and-data_screenshot-crop_NerdGraph-internal-docs.webp "Nerdgraph API example")

You can also use NRQL with our [NerdGraph API](https://docs.newrelic.com/docs/apis/graphql-api/tutorials/nerdgraph-graphiql-nrql-tutorial). This lets you run [cross-account queries](https://docs.newrelic.com/docs/apis/nerdgraph/examples/nerdgraph-nrql-tutorial#cross-account-query) and [asynchronous queries](https://docs.newrelic.com/docs/apis/nerdgraph/examples/async-queries-nrql-tutorial) that aren't available in the UI.

## NRQL query structure [#nrql-rules]

NRQL follows a structured, clause-based syntax. Here's an NRQL query that counts all transactions in the last hour:

```sql
SELECT count(*) FROM Transaction SINCE 1 hour ago
```

Here's a breakdown of all available clauses:

```sql
<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#state-select">SELECT</a> <a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#functions">function(attribute)</a> [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-as">AS</a> 'label'][, ...] 
  <a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-from">FROM</a> data type
  [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-where">WHERE</a> attribute [comparison] [AND|OR ...]][AS 'label'][, ...]
  [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-facet">FACET</a> attribute | function(attribute)]
  [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-limit">LIMIT</a> number]
  [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-since">SINCE</a> time]
  [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-until">UNTIL</a> time]
  [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-timezone">WITH TIMEZONE</a> timezone]
  [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-compare">COMPARE WITH</a> time]
  [<a href="/docs/insights/new-relic-insights/using-new-relic-query-language/nrql-reference#sel-timeseries">TIMESERIES</a> time]
```

Here are the rules that NRQL follows:

| **NRQL rule**                                 | Details                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Required values                               | The [`SELECT`](#state-select) clause and [`FROM`](#sel-from) clause are required. All other clauses are optional. You can start your query with either `SELECT` or `FROM`.                                                                                                                                                                                                                                                                   |
| Query string size                             | The query string must be less than 4 KB.                                                                                                                                                                                                                                                                                                                                                                                                     |
| Case sensitivity                              | Data type names and attribute names are case sensitive. [NRQL clauses and functions](https://docs.newrelic.com/docs/nrql/nrql-syntax-clauses-functions/) aren't case sensitive.                                                                                                                                                                                                                                                              |
| Syntax for strings                            | NRQL uses single quotes to designate strings. The following example shows the syntax: ````sql ... WHERE traceId = '030a573f0df02c57' ```  ````                                                                                                                                                                                                                                                                                               |
| Non-standard custom event and attribute names | Events that we report by default have names that contain alphanumeric characters, colons (`:`), and underscores (`_`). Attribute names can have those characters and periods (`.`). Default-reported names start with a letter. You must enclose custom names that don't follow these guidelines in backticks in NRQL queries. The following example shows a custom name enclosed in backticks: ````sql ... FACET `Logged-in user` ```  ```` |
| Data type coercion                            | We don't support data type "coercion." For more information, see [Data type conversion](https://docs.newrelic.com/docs/insights/nrql-new-relic-query-language/nrql-reference/nrql-syntax-components-functions#type-conversion).                                                                                                                                                                                                              |

For more information, see our [NRQL reference](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions/) to help you build your queries.

## Next steps [#next-steps]

-   [How NRQL works](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/introduction-nrql-how-nrql-works/) (query execution, data freshness, and limits)
-   [Charts and dashboards with NRQL](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/charts-and-dashboards-with-nrql/) (visualize your query results)
-   [Guided NRQL tutorial](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/introduction-nrql-tutorial/) (hands-on walkthrough for new users)
-   [NRQL reference](https://docs.newrelic.com/docs/query-your-data/nrql-new-relic-query-language/get-started/nrql-syntax-clauses-functions/) (full syntax, clauses, and functions)
