Skip to content

Instantly share code, notes, and snippets.

@mujahidk
Created August 30, 2018 19:05
Show Gist options
  • Save mujahidk/c92b2207d53bb0b6e197707ebea4f7c8 to your computer and use it in GitHub Desktop.
Save mujahidk/c92b2207d53bb0b6e197707ebea4f7c8 to your computer and use it in GitHub Desktop.
Node script to get the application list from New Relic API.
var http = require('https')
var options = {
protocol: 'https:',
host: 'api.newrelic.com',
path: '/v2/applications.json',
headers: {
"X-Api-Key": 'you-new-relic-api-key'
}
}
http.get(options, (response) =>{
var data = '';
response.on('data', (chunk) => {
data += chunk;
});
response.on('end', ()=>{
var jsond = JSON.parse(data);
if(jsond.applications) {
jsond.applications.forEach((item, index, array) => {
console.log(`${item.name}=${item.id}`);
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment