Is there a better way to display alerts and alert policies using Nerdpacks?

I am currently working on a Nerdpack that will help us more intelligently investigate alerts (particularly with NRQL based alerts) and I’m trying to find the best way to display any ongoing/previous incidents. I’m able to pull this information from the New Relic API:

function getAPMalerts() {
    let xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function() {

        //Check if request is completed
        if (xhr.readyState == XMLHttpRequest.DONE) {
            //Log return violations to console
            //console.log(xhr.response);
        }
    }

    // Set the request URL and request method
    xhr.open("GET", "https://api.newrelic.com/v2/alerts_violations.json");

    // Set the `Content-Type` Request header
    xhr.setRequestHeader("X-Api-Key", "");

    // Send the requst with Data
    xhr.send();
    return xhr.response;
}

But I’m finding it just a little bit unwieldly… I looked at entities and graphql but there didn’t seem to be existing features that would allow for the display of alert information (like incidents, policies, etc). I tried looking the graphql explorer (https://api.newrelic.com/graphiql) and it seems like it lets you update alerts with mutations but it didn’t look like it just provide that information. I also didn’t see anything for “entities” that listed alerts/policies.

I am still new at this so forgive me if this information is obviously documented somewhere, I can’t seem to find it though. Would it make more sense to try and get this alert information into insights?

Hi @Michael.Sleep

Couple of resources for you…

First, a colleague (@kpeet) has created an ‘Alert Violation Command Center’ Nerdpack. You can see that here: https://github.com/newrelic-experimental/nr1-command-center

The code is all there in Github, so if that doesn’t get you what you need, then you can at least take inspiration from how Keagan has implemented that.

Secondly, @philweber wrote about getting alert data into Insights, see that here:

From then you can run NRQL queries within your nerdpack.

2 Likes