Skip to content

Instantly share code, notes, and snippets.

@ale7714
Created May 21, 2017 23:36
Show Gist options
  • Select an option

  • Save ale7714/8bcc08fb37d4f260cc90dc21b0a6e875 to your computer and use it in GitHub Desktop.

Select an option

Save ale7714/8bcc08fb37d4f260cc90dc21b0a6e875 to your computer and use it in GitHub Desktop.
Copy Datadog Dasboards between accounts
#!/bin/sh
# inspired from https://gist.github.com/lrascao/f57312ff33b799c4c0db56b10e80fe26
from_app_key="$1"
from_api_key="$2"
from_dash_id="$3"
to_app_key="$4"
to_api_key="$5"
dd_dash_url="https://app.datadoghq.com/api/v1/dash"
if [ "$#" -eq 5 ]
then
request_url="$dd_dash_url/$from_dash_id?api_key=$from_api_key&application_key=$from_app_key"
from_dash=$(curl -s GET $request_url | jq '{ title: .dash.title, description: .dash.description, graphs: .dash.graphs}')
curl -i -X POST -H "Content-type: application/json"\
-d "$from_dash"\
"$dd_dash_url?api_key=$to_api_key&application_key=$to_app_key"
else
cat >&2 <<EOM
Error: required params missing
Usage: ./copy_dd_dashboard from_app_key from_api_key from_dash_id to_app_key to_api_key
EOM
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment