Website status incidents via Synthetic script

I want to view the https://status.bandwidth.com/ we would like to know about the incidents happening on that page whether their services are having outage / those are operational and create alert when there is an outage.

So far I created the below script:

var parseString = require('xml2js').parseString;
 
// Get the New Relic status RSS feed
$http.get('https://status.bandwidth.com/history.rss', function(err, response, body) {
  parseString(body, function(err, result){
    // Parse the RSS, and get the latest incident
    var latestIncident = result.rss.channel[0].item[0];
    
    // Push the incident details to New Relic 
    $util.insights.set('Incident', latestIncident.title[0]);
    $util.insights.set('Description', latestIncident.description[0]);
    $util.insights.set('Date', latestIncident.pubDate[0]);
  });
});

Error: http not defined

Could you please help me out in this script so that i can get correct result.

Hi, @agarlapally: You should implement this as an API test. Then the $http object will be defined.

Hi,

Thanks for your response.

So i have selected synthetic monitor → scripted API and pasted that script the validation was successfull but i want to create alert for incident ,outages can you please help me with the query to create it

I am not sure how you would do it using the script as written. Each time your script runs, it will download the RSS feed and push the 20 most recent incidents to New Relic. In order to identify new incidents, you would have to add some logic to your script to save the date and time of the last incident, and only push incidents that have occurred since that time.