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

Is there an api to get a single Alert Condition instead of the list?


#1

I am attempting to write a script that will loop through all of our alert policies and disable every alert condition. I am working in our staging environment right now and we only have a handful of alert conditions.

I know that I can get a list of the alerts using the following endpoint for a specific alert policy:

https://api.newrelic.com/v2/alerts_conditions.json?policy_id=xxxxxx

Is it possible to specify the condition_id to get a json response of just that alert condition and not the list?


#2

It looks like you have a handful of different options here that you could work into your script to get the outcome that you’re looking for.

You might be able to utilize pagination as discussed here. This way, you could break up your request results and have your script evaluate the contents of each page individually. This seems like it might be a bit hacky, but it could be an option nonetheless.

I haven’t done much testing in terms of trying to filter by condition_id, but the option definitely exists as described here.

Finally, here’s some information about Alerts conditions API field names. This should give you some options in terms of querying by different attributes. In your case, I could see this being useful to query for only enabled conditions.

These resources should hopefully point you in the right direction. If I can do anything to clarify these points or help you further, please let me know!


#3

Thank you Masen.

I ended up developing a powershell script that used the python executable for enabling and disabling alerts based on the provided list of policynames that I used the API to gather and update the config file for the python script.

Appreciate your time!


#4

Nice solution! Thanks for letting us know what you did here :smiley: