esnet / gdg

Grafana Dashboard Manager
https://software.es.net/gdg/
Other
343 stars 32 forks source link

import export of a single dashboard #23

Closed mvalletta closed 3 years ago

mvalletta commented 3 years ago

Hi @safaci2000 I think it would be useful to import and export a single dashboard. A use case can be to copy a single dashboard for one organization to another when you have a lot organization and don't want, or can't, copy all dashboards every time.

gdg ctx set -c context_a
gdg dashboard import my-dash
gdg ctx set -c context_b
gdg dashboard export my-dash

Any idea is appreciated, I'm waiting of your feedback to start coding.

safaci2000 commented 3 years ago

Release 1.4 added a partial feature of what you're describing. It may be lacking documentation. I want to revamp the docs in general but you can use the following pattern.

gdg import -d some-dash-slug -d, --dashboard string filter by dashboard slug. If you use the slug you get from the dashboard listing, you can use that to identify the dashboard you want to import/export.

Regarding Orgs:

I can't speak on the orgs since you just pushed that PR but I assume that would still work with the parameters described above.

I think having a 'set' method for the Orgs would be helpful too especially if you keep on switching orgs having the CLI able to manage it would be a nice to have.

If you have a use case where you're moving a resource from org1 to org2 likely adding a copy feature would make sense.

maybe gdg copy -d -o <orgName/Id> which would validate all things and invoke the correct call the the API.

So you'd have something like gdg copy dash -d slug -o org if there's a use case where we need to copy a datasource or other entity we can expand on that.

WDYT?

safaci2000 commented 3 years ago

Actually, now that I think about it a bit more. Let's just attach copy as an action to the resource.

aka gdg dash copy -d slug -o org

If we want to support copy for anything else we can just attach it to the resource as well.

gdg org copy gdg ds copy

etc

mvalletta commented 3 years ago

gdg import -d some-dash-slug fine it works!

I think having a 'set' method for the Orgs would be helpful too especially if you keep on switching orgs having the CLI able to manage it would be a nice to have. I don't understand this point

gdg copy dash -d slug -o org I'll try to work on it but I don't really need this feature because the use case need to modify dashboard JSON before the export:

gdg ctx set -c context_a
gdg dashboard import my-dash
make some changes into dashboard JSON
gdg ctx set -c context_b
gdg dashboard export my-dash
safaci2000 commented 3 years ago
I think having a 'set' method for the Orgs would be helpful too especially if you keep on switching orgs having the CLI able 

to manage it would be a nice to have. I don't understand this point

Just think of it as gdg orgs set ## basically updates the importer.yaml. It's not a big deal just a nice to have.

safaci2000 commented 3 years ago

@mvalletta does the export single dashboard meet your needs? If you don't have a use case for it, I'll probably close this out till someone has a need for it.

mvalletta commented 3 years ago

@safaci2000

does the export single dashboard meet your needs? Yes, it does

If you don't have a use case for it, I'll probably close this out till someone has a need for it. No, I don't have.

safaci2000 commented 3 years ago

Please re-open if this is something that's needed in the future.