Add custom attributes to New Relic Synthetics data

New Relic's $util.insights is a set of tools to set and manipulate Synthetics data for Insights. Custom data is added as custom attributes, with prefix custom, to the SyntheticCheck event. These attributes are in addition to that event's default attributes.

Compatibility

This functionality is available for monitor versions 0.2.0 or later.

Functions

Function Return value

$util.insights.set(key: string, value: ?)

Sets a key/value pair to persist to Insights on job completion.

void

$util.insights.get(key: string)

Returns the value for the provided key that will be persisted to Insights on job completion.

object

$util.insights.getKeys()

Returns an array of keys currently set that will be persisted to Insights on job completion.

object

$util.insights.has(key: string)

Returns true if the key exists in the data that will be persisted to Insights on job completion.

boolean

$util.insights.unset(key: string)

Removes the key/value pair that will be persisted to Insights on job completion.

void

$util.insights.unsetAll()

Removes all custom data to be persisted to Insights on job completion.

void

Example

The example obtains the latest incident from New Relic's RSS status feed and pushes the details to Insights.


var parseString = require('xml2js').parseString;
 
// Get the New Relic status RSS feed
$http.get('https://status.newrelic.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 Insights
    $util.insights.set('Incident', latestIncident.title[0]);
    $util.insights.set('Description', latestIncident.description[0]);
    $util.insights.set('Date', latestIncident.pubDate[0]);
  });
});

For more help

Additional documentation resources include:

Recommendations for learning more: