| name | datadog |
| description | Query metrics, manage monitors, post events, and interact with Datadog via the dogshell CLI. |
| metadata | {"displayName":"Datadog","icon":"activity","category":"monitoring","version":"1.0.0","dependencies":{"cli":"dog","checkCommand":"dog --version","install":{"darwin":{"pip":"datadog"},"linux":{"pip":"datadog"},"windows":{"pip":"datadog"}}},"config":[{"name":"DATADOG_API_KEY","label":"API Key","type":"secret","required":true,"placeholder":"Your Datadog API key"},{"name":"DATADOG_APP_KEY","label":"Application Key","type":"secret","required":true,"placeholder":"Your Datadog Application key"},{"name":"DATADOG_HOST","label":"Datadog Host","type":"string","required":false,"placeholder":"https://api.datadoghq.com"}],"auth":{"type":"api-key","envVars":["DATADOG_API_KEY","DATADOG_APP_KEY"]}} |
dogshell (Datadog CLI)
Use dog to interact with Datadog for metrics, monitors, events, dashboards, and more.
Setup
Before using, set your Datadog API and Application keys:
export DATADOG_API_KEY="your_api_key"
export DATADOG_APP_KEY="your_app_key"
Or create ~/.dogrc:
[Connection]
apikey = your_api_key
appkey = your_app_key
Secure the config file:
chmod 600 ~/.dogrc
Common Commands
Query Metrics
dog metric query --query "avg:system.cpu.user{*}" --start $(date -v-1H +%s) --end $(date +%s)
dog metric query --query "avg:system.memory.used{host:myserver}" --start $(date -v-1H +%s) --end $(date +%s)
dog metric query --query "avg:system.cpu.user{*},avg:system.cpu.system{*}" --start $(date -v-1H +%s) --end $(date +%s)
Post Metrics
dog metric post my.custom.metric 42 --host myserver --tags env:prod,service:api
dog metric post my.custom.metric 42 --timestamp $(date +%s)
Events
dog event post "Deployment Complete" "Deployed version 1.2.3 to production" --tags env:prod,service:api
dog event post "Alert" "High memory usage detected" --priority normal --alert_type warning
dog event query --start $(date -v-1d +%s) --end $(date +%s)
dog event query --start $(date -v-1d +%s) --end $(date +%s) --tags env:prod
Monitors
dog monitor list
dog monitor show <monitor_id>
dog monitor mute <monitor_id>
dog monitor unmute <monitor_id>
dog monitor mute_all
dog monitor create "metric alert" "My Monitor" "avg(last_5m):avg:system.cpu.user{*} > 80" --message "CPU usage is high @slack-alerts"
Service Checks
dog service_check post my.service.check 0 --host myserver --tags env:prod
dog service_check post my.health.check 0 --message "All systems operational"
Dashboards
dog dashboard list
dog dashboard show <dashboard_id>
Hosts
dog host search --query "host:web*"
dog host mute <hostname>
dog host unmute <hostname>
Tags
dog tag show <hostname>
dog tag add <hostname> env:prod role:web
dog tag update <hostname> env:staging role:api
dog tag detach <hostname>
Downtimes
dog downtime schedule --scope "host:myserver" --start $(date +%s) --end $(date -v+1H +%s) --message "Maintenance window"
dog downtime list
dog downtime cancel <downtime_id>
Environment Variables
| Variable | Description |
|---|
DATADOG_API_KEY | Your Datadog API key |
DATADOG_APP_KEY | Your Datadog Application key |
DATADOG_HOST | API endpoint (default: https://api.datadoghq.com) |
For EU region, set:
export DATADOG_HOST="https://api.datadoghq.eu"
Security Notes
- Never commit API keys to version control
- Use Application keys with minimal required permissions
- Store credentials in
~/.dogrc with chmod 600
- Rotate keys periodically
- Use separate keys for different environments
Useful Queries
System Metrics
dog metric query --query "avg:system.cpu.user{*} by {host}"
dog metric query --query "avg:system.mem.used{*}/avg:system.mem.total{*}*100"
dog metric query --query "avg:system.disk.in_use{*} by {device}"
Application Metrics
dog metric query --query "sum:trace.http.request.hits{service:my-app}.as_rate()"
dog metric query --query "sum:trace.http.request.errors{service:my-app}/sum:trace.http.request.hits{service:my-app}*100"
dog metric query --query "p95:trace.http.request.duration{service:my-app}"
Alternative: datadog-ci
For CI/CD operations, use datadog-ci:
npm install -g @datadog/datadog-ci
datadog-ci sourcemaps upload ./dist --service my-app --release-version 1.0.0
datadog-ci junit upload --service my-app ./test-results/*.xml
datadog-ci synthetics run-tests --public-id abc-123