I'm trying to develop a shell script to automatize backups of my Kibana saved objects (dashboards+all related objects)
Running : curl -k -XGET 'https://xx.xx.xx.x:5601/api/kibana/dashboards/export?dashboard=5017f0b0-28a2-11e9-bc68-e1bf949a2fb9' -H 'kbn-xsrf: true' -H 'Content-Type: application/json'
works well and returns my dashboard attributes + visu and index-pattern linked with
I'm now trying to find a way to export all my saved objects and not only one.
Isn't there an easier way to do it than first get all different dashboard ids and export them one by one ?
The export API is limited to certain types of saved objects but can handle dashboards, visualizations, saved search, index patterns. You should be able to pass type: ['dashboard'] and includeReferencesDeep: true to have all your dashboards with dependent objects exported.
{"statusCode":400,"error":"Bad Request","message":"child \"attributes\" fails because [\"attributes\" is required]. \"type\" is not allowed","validation":{"source":"payload","keys":["attributes","type"]}}
Sorry I gave the wrong Kibana version that the feature got delivered in. I was thinking it was 7.1 but it's actually 7.2. I was able to reproduce your issue on 7.1 and get the same error message. I cross checked the pull requests to confirm and that is the case (only as of 7.2 the new APIs are in place).
I think you're hitting the proper API now. The error message you're receiving I believe is because the system can't find the index pattern with id AWM_MwmMTOMwvg7W1USl. Something down the chain must have a broken reference to an index pattern and is failing to export (saved search or visualization possibly).
We have an issue open (https://github.com/elastic/kibana/issues/43876) to allow the export to go through with missing references but at this time the bad reference would have to be fixed before the export is successful.
To find which object is using the missing index pattern, you can use the find API (https://www.elastic.co/guide/en/kibana/current/saved-objects-api-find.html) with hasReference parameter. hasReference: { type: 'index-pattern', id: 'AWM_MwmMTOMwvg7W1USl' }. Depending on the results, you may be able to fix it in the Saved Objects Management section.
I'm sure it will help - was able to make it work without "includeReferencesDeep": "true" anyway
Something on my side now
Thanks again for your appreciated help
And yes, issue #43876 would be a great improvement with warnings at the end of the process saying what went wrong
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.