How to get ids for dashboard

is there a curl command that I can run and get dashboard IDs?
or is there endpoint define which has this information?

I am trying to create a script which does dashboard/viz export in loop.

I have figure out how to do this if I know ids of all dashboards.

Hello @elasticforme

First you can search for Dashboards using the Find API on Kibana.

Then you can Export the Dashboard using the Export Dashboard API on Kibana.

Please consider those APIs are subject to change.

@Luca_Belluccini

That I know, I want to automate this process because I have 10+ space and each has five-six dashboards and three different clusters
means 150 dashboards.

Following command works from bash script and I jsut have to get all the ids for all dashboard. because in my cluster user has access to create what they want and any given day user might create new dashboard. I would like to get that backed up automatically.

curl -u ${elastic_user} -X POST "${URL}${space_name}" -H "kbn-xsrf: true" -H "Content-Type: application/json" -d"
{ \"objects\":[
   {
      \"type\":\"dashboard\",
      \"id\":\"xyxyxyxyxyxyx"
   } ] ,
   \"includeReferencesDeep\": true
}"

The documentation specified the curl commands.

You will need a tool like jq to manipulate JSON responses and iterate through them.

The best way to backup dashboards is to use the Snapshot/Restore capabilities of Elasticsearch, just snapshotting all the indices named prefixed .kibana*.

Something like this will search all the dashboards and generate one file per dashboard.

If you have multiple spaces, you'll need to do another external loop to search for spaces and insert the space id in the URL.

curl -s -k -X GET "${kibanaurl}/api/saved_object/_find?fields=id&type=dashboard&per_page=1000" -u ${user}:${password}  | jq '.saved_objects[].id' | xargs -n1 -I{} curl -s -k -X GET "${kibanaurl}/api/kibana/dashboards/export?dashboard={}" -u ${user}:${password} -o {}.json

actually can't find this on new version.
I am running 7.6.2

curl -s -k -u user:password -X GET "http://elkm01:5601/api/saved_object/_find?fields=id&type=dashboard&per_page=1000"

{"statusCode":404,"error":"Not Found","message":"Not Found"}

Reason I want to save seperate dashboard is because if someone mess up his/her own dashboard I can restore that one. by just backing up whole .kibana* indexes I can't do that.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.