Skip to content

Instantly share code, notes, and snippets.

@Martiflex
Created November 21, 2016 17:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Martiflex/2803a28ec562fc9a15d404a539f85d38 to your computer and use it in GitHub Desktop.
Save Martiflex/2803a28ec562fc9a15d404a539f85d38 to your computer and use it in GitHub Desktop.
# 3p
import requests
# stdlib
import json
import pprint
api_key = 'YOUR_API_KEY_GOES_HERE'
app_key = 'YOUR_APPLICATION_KEY_GOES_HERE'
url = "https://app.datadoghq.com/reports/v2/overview?\
window=3h&with_apps=true&with_sources=true&with_aliases=true\
&with_meta=true&with_tags=true&api_key=%s&application_key=%s"
infra = json.loads(requests.get(url %(api_key,app_key)).text)
for host in infra['rows']:
if (('aws' in host['apps']) and ('agent' not in host['apps'])):
ip = ''
try:
gohai = json.loads(host['meta']['gohai'])
ip = gohai['network']['ipaddress']
except:
pass
print "%s %s" %(host['name'],ip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment