Creating daily snapshots and export them to other systems

Hello everyone,
i want to create daily automated snapshots and export these links to a specific directory on a linux server.
Is there a plugin, API, script via cronjob or something else in Grafana which i could use for this?

best regards,
alessio

1 Like

Hi,

You could use the API, please refer to :

Hope it helps.

Good Luck

1 Like

Hi, thank you for your help.
http API looks interesting. But do you have any advice how to get started?
I see some code for json objects, but i dont know where to use this(grafana/remote system) and which files i need to configure.

bets regards,
alessio

Hi,

Here is an example on how to use the API :

You can then parse the response from curl to fit your needs, in your case you can get the URL from the response either by using system tools (grep,awk…) or using a json parser.

Good Luck

2 Likes

Hi,
i try to use the api to create a snapshot. Therefore i use the json file in my curl command of the server where i want to create a snapshot for:


so my command looks like:

curl -XPOST -H "Authorization: Bearer <key>" -H "Accept: application/json" -H "Content-Type: application/json" -d {..jsno..} <URL>

it returns me :
[{"fieldNames":["Dashboard"],"classification":"RequiredError","message":"Required"}]

am i using the wrong json or is something missing there?

best regards,
alessio

This error indicate a mandatory field missing, did you use the sample from the documentation?

Yes i tried the sample too. It gave me the response like described. But i only copy-pasted it. So no snapshots were actually taken.
I dont know how i should edit the sample that i will take a snapshot of the correct dashboard.

The picture i posted earlier , there is a big json file which contains all the informations from what i want to take a snapshot. but if i use this for my curl i get the error i described earlier.

best regards,
alessio

If i try the URL which i get from the response, it shows me the message
failed create dashboard model
d.panels is undefinded

Now it works, had to provide the right data into the sampler. Now I am working to get the URL. Json parser you said?

Thank you and best regards,
Alessio

If you are working with bash (linux) you can use bash commands (awk, grep) and get the url

Thank you , works like i wanted to.
Just got a little question. refer to:

It says the default expire time is never. The exmaple shows 3600 which is 1hour. Which value can i use that it never expires?
If i use "expires": "never"
it gives me an error

best regards,
alessio

Hi,

Did you try to omit the expires, since it defaults to never.

Good Luck

yes i tried the following
'expires" : "",
"expires": ,
"expires":

gave me always an error becuase of the syntax.

best regards,
alessio

Hi,

I meants remove it completely

1 Like

ah yes that did the trick. thank you!

1 Like

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