How to download opensearch dashboard

Hello team,

Would like to download/export the open search dashboard template from the existing environment. Same template or file can import it to another opensearch dashboard.

Wanted to know is there any file which can be downloaded and then it can be utilised in any of the opensearch dashboard environment?

Any help would be highly appreciated.

Thanks,

Hello,
I wish I could help you but I really have no idea what you are talking about.

Can you give more details? Explain furthermore ?

Are you talking about dashboards inside OpenSearch Dashboards ?
How to import/export saved objects ?

Thi

Hello @ThibaudF,

Thank you for your response…

Yes.

Basically what I am trying to do is I have created a docker-compose file through which the opensearch an opensearch dashboard is getting created. I have created a sample dashboard for that environment.

Now I have created ansible roles through which I am going to deploy the opensearch an opensearch dashboard so I just wanted to use existing dashboard which have created as an example so that will be using the same dashboard in future deployment during using ansible roles.

Please do let me know in case of any questions.

Thanks

Dashboards are exportable via UI/API, you will have JSON so you can use import API during your ansible deployment (after cluster is UP and READY)
Use your web debug console, F12 / CTRL+C and when you export you can get the API used and adapt/modify it.

You can also restore .kibana index (which includes the tenant name)

Thi

1 Like

Thank you so much @ThibaudF

Let me try and update you once done …

Thanks

Edit : In your case, you need the Import API more than the Export API :wink:

Post your results here, it might help others

1 Like

Hello @ThibaudF

Thank you for your response. Actually I am trying to import the exported dashboard using the following command to check whether it is working or not.

curl -X POST http://localhost:5601/api/saved_objects/_import -H “kbn-xsrf: true” --form file=@dashboard.ndjson

curl -X POST “http://localhost:5601/_plugin/kibana/api/saved_objects/_import” -H “kbn-xsrf:true” --form file=@dashboard.ndjson

Unfortunately I am getting an error message 404 page not found.
{“statusCode”:404,“error”:“Not Found”,“message”:“Not Found”}

Can you please suggest how to import it using curl command?

Thank you.

Hi !
Have you tried the parameter ?overwrite=true ?
curl -X POST http://localhost:5601/api/saved_objects/_import?overwrite=true -H “kbn-xsrf: true” --form file=@dashboard.ndjson

Does the dashboard.ndjson exists ?
Check the current directory of the curl command

Don’t forget to add the securitytenant header if you have multi-tenancy enabled

Thank you for your response. Let me try and come back.

curl -X POST http://localhost:5601/api/saved_objects/_import?overwrite=true -H “kbn-xsrf: true” --form file=@dashboard.ndjson → No I have not tried it. Let me try and come back to you.

Does the dashboard.ndjson exists ? → Yes, it is available in my current directory from where I am executing the command.

Don’t forget to add the securitytenant header if you have multi-tenancy enabled → No multi-tenancy

Thanks

Tried with overwrite=true… Getting the following error message.

*** Closing connection 0**
{“statusCode”:404,“error”:“Not Found”,“message”:“Not Found”}Note: Unnecessary use of -X or --request, POST is already inferred.
*** Failed to convert true” to ACE; string contains a disallowed character**

*** Closing connection -1**
curl: (3) Failed to convert true” to ACE; string contains a disallowed character

:frowning:

Try curl with -vvvv and post output

Do you have any authentication system ?
Maybe you need to pass username/password

Have you checked the dashboard.ndjson permissions?

Seems that you are using wrong quote after true, erase and replace the quote
Can you post your dashboard.ndjson content ?

Do you have any authentication system ? → No
Maybe you need to pass username/password

Have you checked the dashboard.ndjson permissions? → made it 777 for now just for testing.

Seems that you are using wrong quote after true, erase and replace the quote
curl -X POST http://localhost:5601/api/saved_objects/_import?overwrite=true -H “kbn-xsrf:true” --form file=@dashboard.ndjson -vvv

Can you post your dashboard.ndjson content ? → Sorry about that. :frowning:

Here is the output of verbose.
Note: Unnecessary use of -X or --request, POST is already inferred.

  • Trying localhost:5601…
  • TCP_NODELAY set
  • Connected to localhost (localhost) port 5601 (#0)

POST /api/saved_objects/_import?overwrite=true HTTP/1.1
Host: localhost:5601
User-Agent: curl/7.68.0
Accept: /
“kbn-xsrf:true”
Content-Length: 32005
Content-Type: multipart/form-data; boundary=------------------------d9a76dd9d9670fad
Expect: 100-continue

  • Mark bundle as not supporting multiuse
    < HTTP/1.1 400 Bad Request
  • no chunk, no close, no size. Assume close to signal end
    <
  • Closing connection 0

FYI, I am using docker container for opensearch-dashaboard and executing the command from host to import the dashboard.

Can you try to add single quotes around file :
curl -X POST http://localhost:5601/api/saved_objects/_import?overwrite=true -H "kbn-xsrf: true" --form 'file=@dashboard.ndjson' -vvv

Can you try some GET on /api/saved_objects ?
Like /api/saved_objects/_bulk_get
Edit : Sorry it was not a GET it’s a POST with bulk_get
So try a request like that : /api/saved_objects/_find?type=dashboard&fields=title&fields=type
To check if GET requests are working correctly before POST
Maybe your endpoint has a prefix
I also have 404 not found if my routes/endpoints/URL are not correct

Have you exported the ndjson via API ? /api/saved_objects/_export endpoint

Can you try to add single quotes around file :
curl -X POST http://localhost:5601/api/saved_objects/_import?overwrite=true -H "kbn-xsrf: true" --form 'file=@dashboard.ndjson' -vvv → Let me try this out…

Can you try some GET on /api/saved_objects ? → Let me try this out
Like /api/saved_objects/_bulk_get

Have you exported the ndjson via API ? /api/saved_objects/_export endpoint → I have exported using GUI… Let me try export using api and update you…

Not able to export the dashboard using API getting 404 error, as same as import.
{“statusCode”:404,“error”:“Not Found”,“message”:“Not Found”}

No luck with get objects.

curl -X GET http://localhost:5601/api/saved_objects/_bulk_get -vvv

Note: Unnecessary use of -X or --request, GET is already inferred.

  • Trying localhost:5601…
  • TCP_NODELAY set
  • Connected to localhost (localhost) port 5601 (#0)

GET /api/saved_objects/_bulk_get HTTP/1.1
Host: localhost:5601
User-Agent: curl/7.68.0
Accept: /

  • Mark bundle as not supporting multiuse
    < HTTP/1.1 404 Not Found
    < osd-name: 65cfd20f3f38
    < content-type: application/json; charset=utf-8
    < cache-control: private, no-cache, no-store, must-revalidate
    < content-length: 60
    < Date: Mon, 18 Jul 2022 13:26:06 GMT
    < Connection: keep-alive
    < Keep-Alive: timeout=120
    <
  • Connection #0 to host localhost left intact
    {“statusCode”:404,“error”:“Not Found”,“message”:“Not Found”}

Thanks.

Yes sorry try again without _bulk_get
GET /api/saved_objects/_find?type=dashboard&fields=title&fields=type

This is what I got after executing the below command.

# curl -X GET http://localhost:5601/api/saved_objects/_find?type=dashboard&fields=title&fields=type -vvv
[1] 1067037
[2] 1067038
{"statusCode":404,"error":"Not Found","message":"Not Found"}-vvv: command not found
[1]-  Done                    curl -X GET http://localhost:5601/api/saved_objects/_find?type=dashboard
[2]+  Done                    fields=title

Put -vvvv before -X GET

Try to make GET requests work first
Maybe the API endpoint changed ?

Try /api/status

Normally it’s still the same : Can we use Kibana REST API's to create the dashboards Programmatically in OpenSearchDashboard - #4 by jong

*   Trying localhost:5601...
* TCP_NODELAY set
* Connected to localhost (localhost) port 5601 (#0)
> GET /api/saved_objects/status?type=dashboard HTTP/1.1
> Host: localhost:5601
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< osd-name: 65cfd20f3f38
< content-type: application/json; charset=utf-8
< cache-control: private, no-cache, no-store, must-revalidate
< content-length: 60
< Date: Mon, 18 Jul 2022 14:06:14 GMT
< Connection: keep-alive
< Keep-Alive: timeout=120
<
* Connection #0 to host localhost left intact
{"statusCode":404,"error":"Not Found","message":"Not Found"}
[1]-  Done                    curl -vvvv -X GET http://localhost:5601/api/saved_objects/status?type=dashboard
[2]+  Done                    fields=title

Tried with /api/status still not working… Not sure, what is missing…

Thanks.