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

Get a list of alert policies and alert channels for all apps

alerts

#1

Hi guys

I am performing an audit on our new relic instrumentation and I want to gather a list of all the apps we have in new relic, along with the alert policies set up for the apps, and where those alert policies are sending their alerts.
The output is an excel spreadsheet that looks a little something like this :-

AppName | AppID | Alert Name | Alert Metric Type | Alert Location
Website1 | 1234 | Alert on errors | error_percentage | test.email@email.com

I have the first 4 columns working by first calling the API at : https://api.newrelic.com/v2/applications.json
That gives me a list of the apps.
I then call alerts entity conditions using the app.Id I got from the above call : https://api.newrelic.com/v2/alerts_entity_conditions/

So that gives me the first 4 columns, but I am struggling to see how I can get the alert policies, and then the email address associated with those alerts.
I can see that I can call alerts_channels.json to get all the alert channels, which contains a list of alert policies for each notification channel. But how can I link the policy ID to the alert entity condition?

The call to alerts_policies.json accepts a policy name, which is what I guess I should be using, but I cant see that returned in any of the calls.

Any ideas?
Thanks!


#2

Hi @brett.howells,

Unfortunately it’s not possible to get a list of alert conditions associated with an application, along with notification channels associated with the policies that those conditions are part of, with a single API call.

First, it’s important to note that the initial REST API call you’re making (to https://api.newrelic.com/v2/applications.json) is listing a detail from the legacy alerting product which was discontinued on May 15 of 2018: alert_policy. This field has no meaning anymore, as alert policies can no longer be associated with applications (the term’s meaning has changed). So, ultimately, there is no way to list alert conditions associated with a given application.

However, you can list out all notification channels, and the IDs from the policies they are associated with will appear in the policy_ids field (https://rpm.newrelic.com/api/explore/alerts_channels/list).

You can also list out all alert conditions of a certain type in a given policy:

Keep in mind, too, that certain types of alert conditions are excluded from the REST API.

So, using the REST API, you can list out your alert policies, notification channels, and most alert conditions, but you will need to manually determine which alert conditions are associated with which application(s) (by looking in the entities field).

All of that said, the idea of being able to list out all alert conditions associated with a given application is an excellent suggestion for an improvement to the product! I would recommend starting a new thread in the Alerts: New Ideas section of the Explorers Hub, which will allow other users to vote on this idea as well as comment on it with possible workarounds.

I hope this helps!