Your data. Anywhere you go.

New Relic for iOS or Android

Download on the App Store    Android App on Google play

New Relic Insights App for iOS

Download on the App Store

Learn more

Close icon

Relic Solution: Custom Events & Custom Attributes



So you’re using Insights, that’s awesome! it’s a great tool out of the box where you can ask critical questions of your data. Like, how many users visited my site today? How many of those visits encountered errors? How slow were the page loads for those users?

All important questions, but what if you could do more? How do you tie those errors or slow pages to the metrics important to a business, like profit? Let’s take a look at custom data.

Wait, what are we doing?

Every system is different, every e-commerce site is different. It would be impossible for New Relic to track some important e-commerce metrics by default simply because of the number of different systems we would need to support for that is huge. Supporting every edge case or “wouldn’t it be nice to have…” scenario is not feasible.

That said it is very easy to send custom data to New Relic, whether you want to create your own events, or tie some new attributes to existing events like PageViews, or Transactions. In this post we’ll be looking at creating custom events, that come with custom attributes.


So how do we do this?

  1. The first step, and probably most important, is to decide what data you need. Nobody wants to look at a dashboard filled with all kinds of unnecessary information. The ideal scenario for most would be to look at a dashboard and at quick glance know exactly what’s going on. So decide what you need to see.
  2. Get that data from your system. This is not something New Relic will be able to do as it involves code changes in your system. The next step goes through sending the data, but you’ll need to determine the best way to capture the metrics you would like.
  3. Next, investigate the best method to send that data. Either the Insights Insert API, or through APM Agents, or you could send them as Browser events.
  4. Now comes actually sending the data. Let’s look at an example…

I’ll be using the Insights Insert API here, to start grab that API key, you can also download an example JSON file in the API Keys page.

The terminal command I’ll use is:

cat example_events.json | curl -d @- -X POST -H “Content-Type: application/json” -H “X-Insert-Key: YOUR_KEY_HERE”{your_account_id}/events

You just need to update the JSON file to suit your needs, the attributes you set are entirely up to you, outside of the reserved words you can let your imagination run wild :smiley:

So what are the possibilities?

Take our example below:
Here we have some revenue metrics, charting as a percentage of our yearly and quarterly goals.

Remember earlier in this post when we spoke about looking at a dashboard at a glance and understanding how we’re doing? Well pictures speak a thousand words, so why not use emoji? You can see above Green is good, yearly we are on track to profit. Quarterly not yet, but we’re making progress. I can see that just by glancing at this page without the need to deep dive on metrics.

To demonstrate the ease here, you can see that charts in this dashboard run with queries like below;

FROM Purchases SELECT sum(revenue) SINCE THIS YEAR

Just for fun…

Now you can see a very small nugget of the possibilities of Custom Events/Attributes, why not play around with it and have some fun.

I work for New Relic, so by extension of that I’m a Data Nerd. I want to see data for ALL THE THINGS. Why not food?

Looking at this you can tell I’m not a calorie counter, I think salads have 1 calorie and spicy burritos have 11 calories. (terribly binary jokes ftw!) - That said, the accuracy of my calorie intake is not the point here. I’m simply trying to demonstrate the possibilities of custom data.

How about some more fun? Add a photo to your dashboard…

Dashboard notes support markdown, so you can if you wish embed images to your dashboard. You may ask why you’d want to do that? Well if you have different dashboards for different business units, why not have an image of the business units team logo (if they have one) to spot which dashboard you’re looking at, at a glance.

As for my dashboard, well I like kittens, so mine has a picture of a kitten.


In the beginning of this post my point was that in an ideal scenario, quickly glancing at the dashboard should give you a good overview of how your applications, servers, e-commerce sites, or business metrics are doing.

To achieve that goal Custom Attributes, Emojis, and Pictures of Kittens were employed. This is though just the bottom of a ladder that could go on forever, the possibilities that come with custom data and Insights are endless. What do you do with Insights? Share with us here on this thread what your best uses for custom data are, and your most creative dashboards.

Additional Resources

NRQL Query to provide Service health with Emoticons
Best Practice Guide: Insights
Explorers Hub Treasure Hunt

Great post @RyanVeitch - An explanation of how to set the green tick or the stop sign based on the query result would be useful. As would the images on your food widget.


Of course, I should have included some of that information :laughing:



You’ll need to take the example_events.json file from the Insights API Keys page. That comes preformatted nicely, allowing you to just copy in your own attribute names and values into the key:value pair format. I copied the emoji from here:

Mine looks something like this:


And my calorie counter query is:

FROM Food SELECT latest(dinner) SINCE THIS WEEK FACET calories

Finding an emoji based on a query is difficult, since you can’t do a WHERE clause on a mathematical operation like below;

FROM purchases SELECT latest(emojiStatus) WHERE sum(revenue) > 30000000 SINCE THIS YEAR

Instead, lets assume the metric you’re tracking here is also being kept track of outside of New Relic, you can run a test on that in code & send the appropriate emoji.

Here’s some very simple pseudocode that might show my thoughts:

if (sum of revenue since January 1st is less than lowerThreshold)
     send {"revenueStatus":"🛑"}
else if (sum of revenue since January 1st is greater than highThreshold)
     send {"revenueStatus":"✅"}

Then the NRQL query you’ll need is:

FROM Purchases SELECT latest(revenueStatus) SINCE THIS YEAR


Embedding images. As I noted, Dashboard Notes support markdown. I recommend checking out for some pointers :smiley:

For my image I use



Thanks for providing the update @RyanVeitch . Is there any supporting documentation in the New Relic docs on tying all this customisation together?

I have repeatedly been asked about RAG dashboards and the information you have currently provided is only part of the solution I need.


Gold stars for Ryan, right @stefan_garnham! Love this post—thank you both!

:star: :star: :star: