New Relic Insights’ query language, known as NRQL, allows New Relic users to run advanced queries against the database of information collected by Insights. These advanced queries let you ask questions about your application or business, providing a valuable view into customer trends or optimization problems on your website.
If you are ready to really dive into New Relic Insights and want to write more complex, advanced NRQL queries, you might want to take a moment to check out this series of short 2-3 minute tutorials from New Relic University. This list will let you jump directly to a specific tutorial on the advanced query you want to learn more about:
- Funnel Queries
- Filter Queries
- Cohort Analysis Queries
- Advanced Segmentation
- Histogram and Heat Map
- Percentile Queries
- Apdex Queries
- Using Math Queries
Let’s take a closer look at each one:
Funnel Queries let you ask questions about the completion of steps in a process, or completion of a series of desired actions. This query format is particularly useful when trying to discover when people exit your site before making a purchase, for example.
Filtering is useful when you have a large chunk of data and you want to narrow the scope by a specific parameter. For example, you might have thousands of user zip codes but you want to view only users in a single zip code. Filtering lets you view only the zip code you want to see.
Cohort Analysis makes it easy to group query results based on different time-based criteria. For example, if you want to know when peak traffic occurs on your application so you can optimize your site to handle those high-traffic times, you might want to break out your data by day like this:
Or you may want even more granular data, breaking out query results by hour, like this:
Advanced Segmentation allows you to break down your data for deeper analysis and then group your results together based on numerical values. This is especially helpful for getting information about things like user engagement. For example, if you want to see the number of users who looked at a page on your site, and then also want to see how long they spent looking at that page, you can write a query that displays the duration of a page view and break out durations by specified amounts.
A Histogram Query creates a chart that is a graphical representation of the distribution of data. Each bar represents a bucket or grouping of data for the value of that attribute. The height of the bar shows the frequency with which events occurred in that particular grouping.
A Heat Map Query is fun variation on a histogram query that allows you to FACET a histogram query to show the intersection of two attributes using lighter and darker colors to indicate frequency.
The Percentile Function is another way to generate a specific chart. This chart is most helpful when accompanied by the TIMESERIES clause, which creates a nice line graph to view percentile data over time.
Of course, your toolbox of advanced queries wouldn’t be complete without the Apdex Function. This function is an easy way to quickly create Apdex charts without affecting charts in any other parts of your New Relic account. You can also use this function to test different t values before making changes in New Relic APM or New Relic Browser. (The apdex t value is a numerical threshold you set based on what your goals are. For more information about setting a meaningful and relevant Apdex t value, check out the New Relic University tutorial Customizing Performance Thresholds.)
You can use this query function to view and compare overall Apdex scores:
You can also view and compare Apdex scores over time using the TIMESERIES function:
Finally, you can use basic mathematical functions in your NRQL queries to explore data in your app. You can apply addition, subtraction, multiplication, and division to both individual attributes as well as to the results of aggregator functions. You can use math with almost any of the other functions covered here to create the perfect chart for viewing your data.