I am trying to use the export/import APIs so I can extract my objects and put them in a repo so they can be loaded in an install script that also does all the elasticsearch mappings and whatnot. I am testing and the export works fine but the import keeps blowing chunks.
I use a script to export - redirected to a file - here's the important part:
DASH_LIST=$(sed -e 's/^"//' -e 's/"$//' <<<`curl -s http://localhost:9200/.kibana/_search?pretty |grep '_id" : "dashboard:' |awk -F[:,] {'print $3'}`)
for DASH in $DASH_LIST
do
curl -XGET -H'Content-Type: application/json' \
http://$KIBANA_HOST:$PORT/api/kibana/dashboards/export?dashboard=$DASH >>./test.json
done
Works fine (see file output below). Then I try the import:
curl -X POST -H 'kbn-xsrf: true' -H 'Content-Type: application/json' "localhost:5601/api/kibana/dashboards/import" --data-binary @./test.json
That's when I get said chunk blowing:
{"statusCode":400,"error":"Bad Request","message":"Invalid request payload JSON format"}
Checking the kibana logs I see this:
Debug: internal, implementation, error
TypeError: Cannot read property 'type' of undefined
at 6.5.0 (/usr/share/kibana/src/legacy/core_plugins/kibana/migrations/migrations.js:481:44)
at tryTransformDoc (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:213:22)
at migrateProp (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:270:11)
at applyMigrations (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:172:11)
at DocumentMigrator.transformAndValidate [as transformDoc] (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:151:43)
at DocumentMigrator.doc [as migrate] (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:47:19)
at KibanaMigrator.migrateDocument (/usr/share/kibana/src/core/server/saved_objects/migrations/kibana/kibana_migrator.js:146:34)
at objects.map.object (/usr/share/kibana/src/core/server/saved_objects/service/lib/repository.js:190:74)
at Array.map (<anonymous>)
at SavedObjectsRepository.bulkCreate (/usr/share/kibana/src/core/server/saved_objects/service/lib/repository.js:174:37)
at SavedObjectsClient.bulkCreate (/usr/share/kibana/src/core/server/saved_objects/service/saved_objects_client.js:45:35)
at EncryptedSavedObjectsClientWrapper.bulkCreate (/usr/share/kibana/x-pack/legacy/plugins/encrypted_saved_objects/server/lib/encrypted_saved_objects_client_wrapper.js:80:89)
at process._tickCallback (internal/process/next_tick.js:68:7)
{"type":"response","@timestamp":"2019-11-21T18:23:37Z","tags":["api"],"pid":6,"method":"post","statusCode":400,"req":{"url":"/api/kibana/dashboards/import","method":"post","headers":{"host":"localhost:5601","user-agent":"curl/7.58.0","accept":"*/*","kbn-xsrf":"true","content-type":"application/json","content-length":"77870","expect":"100-continue"},"remoteAddress":"172.18.0.1","userAgent":"172.18.0.1"},"res":{"statusCode":400,"responseTime":18,"contentLength":9},"message":"POST /api/kibana/dashboards/import 400 18ms - 9.0B"}
Which doesn't mean much. I do believe that the stack trace has nothing to do with this, but I can't tell from the formatting of the log.