2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Redash】Dashboard をコピー(複製)する

Last updated at Posted at 2021-05-10

1. はじめに

 データ分析基盤をマーケター向けに作成しており、可視化ツールとしてredashを採用しています。redashは非エンジニアの方でもsqlが書ければ、手軽にデータをプロットできるので使い勝手が良いです。しかしながら、特定の機能についてはAPIを叩く必要があります。タイトルの通り、DashboardのコピーについてはGUIからはできませんが、APIを叩いて複製する方法があったので共有します。

2. 環境・前提

①コピーしたいダッシュボードのurlを確認
 ex) https://redash.example.com/dashboard/example_test_board

②python実行環境 (python > 3.x)

3. 準備

  1. redash_host(urlのホスト部分)
  2. Slug(urlの最後の部分)
    • example_test_board
  3. User API key
    • Redashログイン>右上のアイコンクリック>Edit Profile>API Key を確認
  4. 複製クエリ名を考える(元のクエリ名の頭に付与される)
    • copy_smoto_

4. 方法

redash-toolbeltをクローンする(※redash製のAPI簡易ラッパーです)
② クローンしたコード example/clone_dashboard_and_queries.py を実行

python clone_dashboard_andqueries.py {redash_host} {slug} {コピー名}

ex) python clone_dashboard_and_queries.py https://redash.example.com/ example_test_board copy_smoto_

③ API Key を問われるので、確認した API Key を入力

[xxx/redash-toolbelt/redash_toolbelt/examples] % python clone_dashboard_and_queries.py https://redash.example.com/ example_test_board copy_smoto_
API Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

④ コピー結果の確認(redash)

ダッシュボード名: Copy of: example_test_board
クエリ: copy_smoto_xxxx

5. 備考

  • ダッシュボードを複製すると、クエリも全てコピーされます(テストでクエリがたくさんあるボードをコピーすると、削除するのが大変です)
  • User API Key の取り扱いには注意してください (以下引用)

All the API calls support authentication with an API key. Redash has two types of API keys:
User API Key: has the same permissions as the user who owns it. Can be found on a user profile page.
Query API Key: has access only to the query and its results. Can be found on the query page.
Whenever possible we recommend using a Query API key.

参考

2
0
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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?