Export dashboard for external use via HTTP API

Hi Grafana!

  • What Grafana version and what operating system are you using?
    7.5.5 and 8.0.6

  • What are you trying to achieve?
    Export dashboards for sharing externally via HTTP API

  • How are you trying to achieve it?
    curl -s -b “$COOKIE” “$HOST/api/dashboards/uid/$dash”

  • What happened?
    Dashboard is exported without __inputs or named datasources

  • What did you expect to happen?
    I hoped there would be an option in the API to export for sharing externally, but I didn’t find it.

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No errors, none expected

  • Did you follow any online instructions? If so, what is the URL?
    Dashboard HTTP API | Grafana documentation

I found these very similar requests (no response) from 2 and 3 years ago(apologies for not including the actual links, I’m not allowed to do that yet):
27886
23761
16037
I am hopeful that this indicates that I missed something trivial, that would be typical.

Thanks very much in advance!

5 Likes

@jeremybz did you ever found the answer? This is a very valid question and I’m surprised it doesn’t attract more interest.

Hi @glep207, unfortunately I have not yet found a solution for this.

Hi Jeremy,

are you aiming to export the JSON representation or the bitmap image of the dashboard?

With kind regards,
Andreas.

Hi Andreas,
My goal is to use the API to get the JSON representation of a dashboard, including __inputs and named datasources.
Interestingly, in 8.3.x I see that using the web interface to export any dashboard with “Export for sharing externally” set to true generates only the following JSON:{“error”:{}}. This is certainly a separate issue.
Best regards,
Jeremy

HTTP API for dashboard export for external use doesn’t exist. This export feature is implemented in the UI (frontend). I would say the only option is to use standard dashboard API and make that output transformed into “dashboard format for external use”. Unfortunately, that format is not documented, so you have to use reverse engineering.

Hi Jan!
I think the HTTP API is the same as the standard dashboard api, or at least we’re both linking to the same page. I don’t see how the datasource information is available from the API. By “use reverse engineering”, are you suggesting a selenium-like script, or something better that I’m missing?

You can read the source code. You can export dashboard via API and then via UI (with external use) - then compare results and write transformations, …

1 Like

Hi again,

Oh, I see. I believe I never saw that format before, thank you! On this matter, I should have followed your original references.

While I have nothing significant to contribute now, I still want to reference the corresponding place in the code base, where this JSON representation is generated. It is DashboardExporter.ts.

Also, I created a note at Add converter for dashboard JSON in "export format" representation · Issue #8 · panodata/grafana-client · GitHub about this. I will be happy to hear your opinions about it.

With kind regards,
Andreas.

3 Likes

Thanks very much! This takes us a big step closer to a solution.
Just to confirm what I think you and @jangaraj are saying: DashboardExporter takes a DashboardModel which is constructed based solely on the output of the http api. Is this correct?

still no api to export dashboard externally ?

1 Like

Just for the records. We started with an implementation but haven’t been able to complete it, yet.

Contributions from people who love to mangle nested data structures and know Grafana and Python will be very much appreciated on this.

1 Like

This topic was automatically closed after 365 days. New replies are no longer allowed.