Advanced NRQL Queries
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. The menu dropdown on the left will let you jump directly to a specific tutorial on the advanced query you want to learn more about.
Here’s a quick overview of each one:
With Funnel Queries you can 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 viewers who watched tutorials, but only want to see data for viewers who watched at least 50% of a tutorial. Filtering lets you view data for only those views.
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:
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 pageview 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. 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.