-
-
Save Martiflex/2803a28ec562fc9a15d404a539f85d38 to your computer and use it in GitHub Desktop.
This file contains 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
# 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