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
# Executes a query of Datadog to identify hosts that have a specified metric | |
# over the previous day. | |
# Assumes that first parameter is the name of a metric. | |
# Example: ./get_metric_hosts.sh inf.backup.sizeScanned | |
# Requires that Datadog credentials be implemented in environment variables | |
# DATADOG_API_KEY and DATADOG_API_KEY. | |
# Requires that jq is installed. | |
metric=inf.backup.errCode # by default | |
if [ "$1" != "" ]; then |
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
# 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' \ |