LoginSignup
4
3

More than 5 years have passed since last update.

Datadogでアカウントをまたいでdashboardをcopyする

Last updated at Posted at 2018-03-22

メトリクスの混在を防ぐために、本番用のDatadogアカウントに加えてテスト用のdatadogアカウントを作ったのですが、
本番にあるdashboardをテストアカウントに持って行こうとした時に、地味に面倒だったのでその時のメモ。

tl;dr

  • datadogのdashboardをアカウントを跨いでcopyする時は↓が便利。ただ、fieldが欠けていたりするかもしれないので、適宜スクリプトの修正が必要かも。
    https://github.com/ouyi/dashjson

問題点

dashboardをjsonでexportする機能は提供されているので、それをベースにそのままimportしようとするが、
{"errors": ["The parameter 'title' is required"]}

というエラーになってしまい、上手くいかない。。

色々ググっていくと、↓のgistを発見。
https://gist.github.com/lrascao/f57312ff33b799c4c0db56b10e80fe26
微妙にexportしたjsonの構造をいじらないといけないということを知る。。

解決策

github上に↓のスクリプトを発見。
https://github.com/ouyi/dashjson
こんな感じで、直接値を取り出しているので、
https://github.com/ouyi/dashjson/blob/6ae736f66dd6fc1b2cc540c247d38cd78f1fbea4/dashjson.py#L29-L30
READMEの通りにやって、とりあえず動いた。

# export-credential は本番用。
$ python dashjson.py -e DASHBOARD_NAME.json -d DASHBOARD_ID -c export-credential.json
# import-credential はテストアカウント用。 -nをつけないと、updateになるので今回のケースでは指定が必要。
$ python dashjson.py -t t -i DASHBOARD_NAME.json -c import-credential.json -n

が、微妙に上手くコピーできていないのもあり、スクリプトに手を入れた。
https://github.com/ouyi/dashjson/pull/1

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3