Not able to view saved object after importing via API

Hi,

I imported multiple saved_objects (index-pattern, visualization, dashboard) via POST /api/saved_objects/_import API. It gives successful response code -200 as response code for all saved objects.
But when i check in Kibana, some saved objects are missing.
Its very random and there is no fixed file which is not able to be imported.This is observed very inconsistently.
What can be the reason for this?

I am using 7.2 version of Kibana.
Can we please get some help here?

Hello,

let me ask you few things to understand better the problem:

  • Are you importing saved object exported via API or via GUI? (unfortunately at the moment you can only export-import using the same means, export API - import API, export GUI - import GUI)
  • How did you find out that some saved_objects are missing? some dashboard and visualization were missing or you used the saved_object API to retrieve the available saved_objects?
http://localhost:5672/api/kibana/management/saved_objects/_find?type=visualization&type=index-pattern&type=dashboard
  • last question: where the saved object exported in an older version of kibana?

@markov00

  • I exported all the saved objects files via GUI. And then using the same ndjson files to import via API.
    If we can only export-import using the same means, export API - import API, export GUI - import GUI, then why major saved objects are successfully imported only few are failing?

I have around more than 100 saved object files and explicitly export individual object with API and then saving in a separate ndjson file and then import with API is a very tedious job. Is there any better way to achieve it?

  • I found out some saved_objects are missing in GUI as there is mismatch in count between the objects imported and the objects which i imported from the API.
    Even i checked with GET /api/saved_objects/<type>/<id> API to check the presence of saved object. The response was saved object not found

  • All the exported saved objects (.ndjson) files are stored in a folder. From this folder api is trying to import the files via API.

You are right, I'm sorry, the issue I was reporting about the incompatibility of exported saved objects between API and GUI doesn't exist in the case the GUI you are referring to is the Management -> Saved Objects (I was referring to exporting a dashboard saved object from the Dashboard UI and importing it through API). Sorry for the confusion.

I have around more than 100 saved object files and explicitly export individual object with API and then saving in a separate ndjson file and then import with API is a very tedious job. Is there any better way to achieve it?

Sure, you can export saved object by types and you can download all types at ones with this:

POST api/saved_objects/_export
{
    "type": [
        "config",
        "map",
        "canvas-workpad",
        "canvas-element",
        "index-pattern",
        "visualization",
        "search",
        "dashboard",
        "url"
    ],
    "includeReferencesDeep": true
}

This will return all the saved object available in kibana (is exactly the same function called by the UI when you export all your objects.

Than you can import that using

$ curl -X POST "localhost:5601/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@YOUR_EXPORTED_FILENAME.ndjson 

And it should import all your object.
The response should also contains a message like the following that contains the number of imported objects, and the status of the import (together with errors if any)

{
  "success": false,
  "successCount": 1,
  "errors": [
     // list of errors
  ]

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