• Log in

Query custom business data

15 min

lab

This procedure is part of a lab that teaches you how to monitor your application with New Relic.

Each procedure in the lab builds upon the last, so make sure you've completed the last procedure, Collect custom business data, before starting this one.

With your app recording custom business data, you're now ready to get insights from your data. Particularly, you look up:

  • Orders from the past 24 hours
  • Most popular restaurants
  • Most active customers
  • Average order amount
  • Customers that spend the most money
  • Most popular items

In this procedure, you create a dashboard, query your custom data, gather it in charts, and add those charts to your dashboard to have quick view into these data points.

Create a dashboard

With New Relic dashboards, you observe and interpret the data you collect from your application. You gather the data you want to see into charts to customize the way you see it.

Step 1 of 4

Navigate to New Relic and sign in with your account.

Step 2 of 4

Under Dashboards, click Create a dashboard in the top right corner.

Arrow pointing to Create a dashboard

Step 3 of 4

Select Create a new dashboard.

Arrow pointing to Create a new dashboard

Step 4 of 4

Name your dashboard "FoodMe", and click Create.

Arrow pointing to Create button

Add charts to your dashboard

Once the dashboard is in place, you can start creating charts to answer your business related questions.

Orders in past 24 hours

Hover over the dashboard, and click Add a new chart.

add a new chart

From this screen, you add charts using our query builder, or you choose to add text, images, or links using Markdown.

Step 1 of 4

Click Add a chart.

add a chart

This opens a query builder.

Step 2 of 4

Switch to the NRQL editor.

add a chart

Step 3 of 4

Edit the query as follows.

SELECT count(*) AS 'Orders' FROM Transaction WHERE appName='food-me' AND name LIKE '%/api/order' SINCE 1 day ago

orders in past 24 hours chart

Here, you see the number of orders for the past 24 hours.

Step 4 of 4

Name your chart "Orders in past 24 hours", and click save.

Add chart to dashboard

The chart is now visible on your dashboard.

You can add more charts to your dashboard following the same pattern. To do so, click + in upper right-hand corner.

Add more charts to your dashboard

This takes you to the same Add to your dashboard page.

Add another chart to your dashboard.

Run the following query to view the most popular restaurants for your FoodMe app.

SELECT count(*) FROM Transaction WHERE appName='food-me' AND name LIKE '%/api/order' AND restaurant IS NOT NULL FACET restaurant SINCE 1 day ago

View popular restaurants

This chart shows you the most popular restaurants. Change the chart type to Pie, name it "Most popular restaurants", and click save to add it to your dashboard.

Most popular restaurants pie chart

Most active customers

For a chart showing the most active customers, use the following query.

SELECT count(*) FROM Transaction WHERE appName='food-me' AND name LIKE '%/api/order' AND customer IS NOT NULL FACET customer SINCE 1 day ago

Here, you observe your most active customers.

Most active customers chart

Average order amount

Use the following query to calculate the average order amount.

SELECT average(orderTotal) FROM Transaction WHERE appName='food-me' AND name LIKE '%/api/order'

Average order chart

Here, you see observe the average order amount.

Most money spending customers

Execute the following query to view which customers spend the most money ordering food from your app.

SELECT sum(orderTotal) FROM Transaction WHERE appName='food-me' AND name='WebTransaction/Expressjs/POST//api/order' FACET customer

Most money spending customers

Here, you observe the most money spending customers.

Use the following query to view the most popular items.

SELECT sum(qty) FROM PageAction WHERE actionName='orderItem' FACET item

Most popular items

Here, you observe the most popular items for your app.

Your final dashboard looks something like this:

Final dashboard

Filter your dashboard

You now know how well your business is performing. You can filter your dashboard by restaurant, and get a closer look.

Step 1 of 2

Click ... in front of your "Most popular restaurants" chart, and select Edit.

Edit most popular restaurant chart

Step 2 of 2

Toggle Filter the current dashboard to enable the filter and save.

Enable filter

Now, you see the option to filter dashboard by most popular restaurant.

Filter this dashboard

The dashboard now shows you business data related to that restaurant.

Filtered dashboard

Summary

In this procedure, you created a dashboard and added multiple charts to it to get business insights.

lab

This procedure is part of a lab that teaches you how to monitor your application with New Relic. Continue on to next procedure, Add alerts.

Copyright © 2022 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.