Forking a dashboard

Forking a dashboard

This would help very much and save hours for us. The current situation is that if we want to have two similar dashboard, that differ only in their parameters, we need to add widget by widget to each dashboard. We want to prevent this repetition and time-cost for these cases where dashboard are so similar. It would be of great value to us.

Optimally, we would want to have the option to copy a dashboard. This way, we can have two (or more) similar dashboards, which will differ in the parameters we pass in to them.
Thanks!

The problem I’ve noticed with this is that each query can only cache one result at a time. If you change the params, the previous cached results are lost, and your other dashboards all return errors.

I’m trying to figure out a way around this too, so I can have 1 query, pass different params on each dashboard, and cache results for each. But right now it doesn’t seem possible?

This is correct.

The accepted way to fork a dashboard is using the API to rebuild it from scratch. If you need the results to cache then you would also fork the queries.

Is there any plans to add this functionality in the near future?

1 Like

It’s not part of the product, but we’re preparing an API script that can do this automatically. You can follow development here:

1 Like

@dietdrpepper this sounds great, but any chance for an a short walkthrough on how to use it?

Here is my attempt

  1. pip3 install redash_toolbelt (not sure if this is needed but it did quell some loud noises)
  2. git clone git@github.com:getredash/redash-toolbelt.git
  3. cd redash-toolbelt
  4. git checkout issue-14
  5. pip3 install click
  6. python3 -m redash_toolbelt.examples.clone_dashboard_and_queries https://bla.bla.com/ blop-dash pref-blip

OK, this worked.
I followed this up with some scripts to update the queries in a dashboard to a new data source.

for reference this returns the dashboard id, slug, and query ids, for further editing.

dashj = requests.get(url=f'{base}/api/dashboards/{dash["slug"]}', headers=headers).json()
ans = {s:dashj[s] for s in 'slug name id'.split()}
ans['queries'] = [dd['visualization']['query']['id'] for dd in dashj['widgets'] if 'visualization' in dd]

and this is enough to edit the query

json = {'query': query,
            'name': qname, 
            'data_source_id': client_data_source_id,
            'is_draft': False
            }
        
        # update
    res_post= requests.post(url=f'{base}/api/queries/{id}', headers=headers, json = json)

note: after changing the data source for a query you probably want to refresh the results by posting to f'{base}/api/queries/{id}/results'

1 Like

I did this feature, if you also need, contact me.

do you have it in a branch?

I am a fresh man, I am learning how to pull request.

I post my python code on this branch, if you also need js code, i can post it too.

You can contact me, This is my github link