Skip to content

Instantly share code, notes, and snippets.

@doerodney
Created June 14, 2019 21:05
Show Gist options
  • Save doerodney/bde2c49ce26257a70d7fc0edaf3f440f to your computer and use it in GitHub Desktop.
Save doerodney/bde2c49ce26257a70d7fc0edaf3f440f to your computer and use it in GitHub Desktop.
Executes the Datadog API reports/v2/overview.
# Executes the Datadog API reports/v2/overview query.
# Uses jq to flatten the JSON output to a CSV file for easy import into Excel.
# Requires that Datadog credentials be implemented in environment variables
# DATADOG_API_KEY and DATADOG_API_KEY.
outfile=overview.csv
echo "DisplayName,HostName,Name,SocketFqdn,AwsId,AwsName,AgentVersion,Platform,Machine" > "${outfile}"
curl -G "https://api.datadoghq.com/reports/v2/overview?api_key=${DATADOG_API_KEY}&application_key=${DATADOG_APP_KEY}&with_meta=true" \
| jq '.rows[] | "\(.display_name),\(.host_name),\(.name),\(.meta | ."socket-fqdn"),\(.aws_id),\(.aws_name),\(.meta | .agent_version),\(.meta | .platform),\(.meta | .machine)"' \
| sed -e 's/null//g' -e 's/"//g' \
>> "${outfile}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment