You can get a lot out of New Relic Insights, our powerful real-time analytics platform, right out of the box. But the New Relic Query language, or NRQL, lets you do even more. NRQL makes it easy to query data collected from your applications and transform that data into charts that help you interpret what your data says about your application and your business.

If you are unfamiliar with NRQL, you might want to check out this quick New Relic University video tutorial: Intro to NRQL. In just 10 minutes, it covers the basic syntax of a NRQL query, introduces some commonly used functions, and presents an overview of how to use the query tool.

 

NRQL is a database querying language, similar to SQL. It queries against your New Relic events database, making it easy to create charts with data about your applications. Once you make a query, data comes back in a JSON format, which Insights’ widgets use to build meaningful charts.

Here is a sample of JSON that might be returned from an Insights NRQL query:

JSON sample

It is helpful to know what attributes are recorded in your Insights account so you can write useful and meaningful queries using all your available data. In order to find out what data you have to work with, watch Introduction to Insights, a video tutorial that covers how to navigate the Data Explorer page in detail.

Brainstorm your questions first

Once you are familiar with your data, you may find it helpful to brainstorm some questions you want to ask in Insights before you start writing queries.

In this tutorial, you will see query examples designed to answer questions such as:

  • How many total sessions have there been on my site?
  • What cities are my users coming from?
  • What transactions occur most frequently?
  • How long does it take for pages to load for users?
  • Is backend or frontend browser response taking more time to complete?

As you type out your queries, you’ll notice that a list of keywords appears for you to choose from. You can either click on the word you want, or use the arrow keys to move up and down the list and then hit the Tab key to enter the word into the query tool.

The choices are suggestions for NRQL clauses, functions, attributes, or events that may fit into that part of your query. Suggestions are based on the structure of the query as it stands up to that point, and are based on the last hour of relevant event data your app has sent to New Relic Insights.

The tutorial walks you through how to write a query that answers simple questions like “How many total sessions have there been on my site?”

Which result in simple display results like this:

query response example

More complex versions of this and other questions give you more interesting and detailed charts and information like this:

wilmington example

Seeing patterns and trends in your data

Perhaps most importantly, the tutorial covers how to use the TIMESERIES function. TIMESERIES is a powerful and useful function because most of your New Relic Insights data is based on events that occur over time.

Using the TIMESERIES function lets you see your data live in real time over a specified time period. When the TIMESERIES function is added to the query that gave us the chart above, it is transformed into an hourly breakdown of data that displays patterns and trends over time.

TIMESERIES chart

If you want to better understand and improve your website’s performance, it’s well worth taking 10 minutes to watch the tutorial and learn some NRQL basics and get started developing charts and dashboards in New Relic Insights. To learn more, check out the related topics on the New Relic Community Forum: Video: Intro to NRQL.

See also: Writing Advanced Queries in New Relic Insights [Video]

 

Background image courtesy of Shutterstock.com.

Erica Lauer Vose is manager of New Relic University’s online education team. She brings more than 16 years experience as a trainer and over 10 years experience with instructional design. In 2012, she co-founded a Code School and joined the New Relic University team in 2014. View posts by .

Interested in writing for New Relic Blog? Send us a pitch!