Skip to content

Instantly share code, notes, and snippets.

@denizozger
Created March 10, 2017 13:23
Show Gist options
  • Save denizozger/14ecd1be149784a57fee756c100b30c0 to your computer and use it in GitHub Desktop.
Save denizozger/14ecd1be149784a57fee756c100b30c0 to your computer and use it in GitHub Desktop.
New Relic Synthetics Monitoring Script
var assert = require('assert');
var options = {
'auth': {
'user': 'USER',
'pass': 'PASS',
'sendImmediately': false
}
};
console.log('Node ', process.version)
$http.get('SOME-URL', options, function (err, response, bodyStr) {
console.log('Response:', bodyStr);
assert.equal(response.statusCode, 200, 'Expected a 200 OK response');
var body = null
try {
body = JSON.parse(bodyStr)
} catch (e) {
// this service didn't implement the new format, validation above will need to be enough..
}
if (body) {
Object.keys(body).forEach(function(k) {
const v = body[k]
assert(v.toLowerCase().indexOf('up') !== -1, (k + ' is not up'))
})
}
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment