Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Having trouble with create_new_snapshot() function #83

Open
smartyrahul opened this issue Oct 30, 2020 · 1 comment
Open

Having trouble with create_new_snapshot() function #83

smartyrahul opened this issue Oct 30, 2020 · 1 comment

Comments

@smartyrahul
Copy link

First of all I am really thankful for your efforts to create this very useful library.

Now, I am having trouble with create_new_snapshot api, as when I use it, instead of static data, dashboard is keep on showing new data. Now interesting thing is, this is only happening if I am exporting it to snapshot.raintank.io, if I take local snapshot, it works fine.

Here is the code I used:

ref = grafana_api.search.search_dashboards()

for r in ref:
    print(r)
    dashboard1 = grafana_api.dashboard.get_dashboard(r['uid'])
    if r['uid'] == 'gatling':
        res = grafana_api.snapshots.create_new_snapshot(name="run_id_24"+r['title'], dashboard=dashboard1['dashboard'], external=True, key="abcd")
        print(res)
        break

Versions

  • Grafana: [7.2.1]
  • grafana_api: [ 1.0.3]
  • Authentication: [Basic]

So can you guys help me with it.
Here I am attaching one of the snapshot link.

@peekjef72
Copy link

As far as I know, Grafana API doesn't provide any method to generate a snapshot content.
The api provided by grafana, and thus this python interface only give you a way to store a "json" content in grafana database.
If you want to build snapshot, you have to retrieve the dashboard and then get the data from the datasource and store the result in a valid format in JSON, and only then you can use the API to store the result.
You may have a look at the project https://github.com/peekjef72/grafana-snapshots-tool (still beta).
Feel free to give me some feebacks about it or if you have troubles in the installation part: I've produced some pull requests on grafana-api that is requirered for granafa-snapshoots-tool to work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants