Created
August 30, 2018 19:05
-
-
Save mujahidk/c92b2207d53bb0b6e197707ebea4f7c8 to your computer and use it in GitHub Desktop.
Node script to get the application list from New Relic API.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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