Grafana api powershell

Hi,
I use Grafana V8.5.13. I’m new in powershell and Grafana.

I want to export all dashboards with a powershell script. When i want to do a curl :

curl MyUrl/api/folders/
i have this message :

{“message”:“Unauthorized”}

Thanks in advance.

Wilfrid

Hello

Have you rewd the following documentation?

Hi,

Yes, all HTTP API documentation.

Will

on Chrome when i type MyUrl/api/folders, i have what i want :

[{“id”:24,“uid”:“vFCSdTNVk”,“title”:“Business”},{“id”:23,“uid”:“h9i97TH4k”,“title”:“ISO - Monitoring”},{“id”:20,“uid”:“9A6jMoNVz”,“title”:“ISO - Windows”},{“id”:1,“uid”:“po8qW8fMk”,“title”:“Monitoring - Alerts”},{“id”:8,“uid”:“pFfHMUBMz”,“title”:“Monitoring Infrastructure”}]

But to do it programatically it is abiy different you need to provide authorization bearer token

oh yes, here my powershell code :

$GrafanaURL = MyGrafanaURL/api/folders"

[String]$Key = MyKey
$Headers = @{ Authorization = “Bearer $($Key)”}
$folders = Invoke-RestMethod -Uri $GrafanaURL -Method Get -Headers $Headers -ContentType ‘application/json’;

Write-Host $folders

And the result is that $folders is empty.

You want dashboards right per original post?

"want to export all dashboards with a "

Yes the goal is to export all dashboards in json or csv format from all my folders.
I use this :

Thanks for your help.

1 Like

Check this out its with python but you can port the idea to powershell

Many thanks for your help :+1: :+1: :+1: :+1: :+1: :+1:

1 Like

what is the purpose of this effort? What are you trying to solve?

I started a new job and i’m new in powershell. The goal it’s to import all dashboards in TFS.

2 Likes

another option is to also backup the following folders

data
conf