Issue with reusing dashboard on another index

I'm trying to reuse the dashboard i have on another index. I downloaded the file from saved objects which is in ndjson format and edited following fields
index name, index id(uuid), dashboard name and dashboard id(uuid) and uploading it with REST API.

curl -X POST "localhost:5601/api/kibana/dashboards/import?exclude=index-pattern" -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d @dashboard.json

This is the [part of] dashboard.json

{

 "objects":[

 {"attributes":{"description":"index: one_8apr_1","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Overall Conversations-1","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"Overall Conversations\",\"type\":\"metric\",\"params\":{\"metric\":{\"percentageMode\":false,\"useRanges\":false,\"colorSchema\":\"Green to Red\",\"metricColorMode\":\"None\",\"colorsRange\":[{\"type\":\"range\",\"from\":0,\"to\":10000}],\"labels\":{\"show\":true},\"invertColors\":false,\"style\":{\"bgFill\":\"#000\",\"bgColor\":false,\"labelColor\":false,\"subText\":\"\",\"fontSize\":60}},\"dimensions\":{\"metrics\":[{\"type\":\"vis_dimension\",\"accessor\":0,\"format\":{\"id\":\"number\",\"params\":{}}}]},\"addTooltip\":true,\"addLegend\":false,\"type\":\"metric\"},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"cardinality\",\"schema\":\"metric\",\"params\":{\"field\":\"conversation_id.keyword\",\"customLabel\":\"  \"}}]}"},"id":"dd7337d0-797d-11ea-b521-59fdf02d9efc","migrationVersion":{"visualization":"7.4.2"},"references":[{"id":"af87feb0-7963-11ea-b521-59fdf02d9efc","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"type":"visualization","updated_at":"2020-04-20T11:26:46.370Z","version":"WzY4OCwxXQ=="},

 {"attributes":{"description":"index: one_8apr_1","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Successful Conversations-1","uiStateJSON":"{}","version":1,"visState":"{\"aggs\":[{\"enabled\":true,\"id\":\"1\",\"params\":{\"customBucket\":{\"enabled\":true,\"id\":\"1-bucket\",\"params\":{\"filters\":[{\"input\":{\"language\":\"kuery\",\"query\":\"resolution_response:YES\"},\"label\":\"\"}]},\"schema\":{\"aggFilter\":[],\"editor\":false,\"group\":\"none\",\"max\":null,\"min\":0,\"name\":\"bucketAgg\",\"params\":[],\"title\":\"Bucket agg\"},\"type\":\"filters\"},\"customLabel\":\"   \",\"customMetric\":{\"enabled\":true,\"id\":\"1-metric\",\"params\":{\"customLabel\":\"      \"},\"schema\":{\"aggFilter\":[\"!top_hits\",\"!percentiles\",\"!percentile_ranks\",\"!median\",\"!std_dev\",\"!sum_bucket\",\"!avg_bucket\",\"!min_bucket\",\"!max_bucket\",\"!derivative\",\"!moving_avg\",\"!serial_diff\",\"!cumulative_sum\",\"!geo_bounds\",\"!geo_centroid\"],\"editor\":false,\"group\":\"none\",\"max\":null,\"min\":0,\"name\":\"metricAgg\",\"params\":[],\"title\":\"Metric agg\"},\"type\":\"count\"}},\"schema\":\"metric\",\"type\":\"sum_bucket\"}],\"params\":{\"addLegend\":false,\"addTooltip\":true,\"dimensions\":{\"metrics\":[{\"accessor\":0,\"format\":{\"id\":\"number\",\"params\":{}},\"type\":\"vis_dimension\"}]},\"metric\":{\"colorSchema\":\"Green to Red\",\"colorsRange\":[{\"from\":0,\"to\":10000,\"type\":\"range\"}],\"invertColors\":false,\"labels\":{\"show\":true},\"metricColorMode\":\"None\",\"percentageMode\":false,\"style\":{\"bgColor\":false,\"bgFill\":\"#000\",\"fontSize\":60,\"labelColor\":false,\"subText\":\"\"},\"useRanges\":false},\"type\":\"metric\"},\"title\":\"Successful Conversations\",\"type\":\"metric\"}"},"id":"2b0af950-7a60-11ea-b521-59fdf02d9efc","migrationVersion":{"visualization":"7.4.2"},"references":[{"id":"af87feb0-7963-11ea-b521-59fdf02d9efc","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"type":"visualization","updated_at":"2020-04-20T11:26:46.370Z","version":"WzY4OSwxXQ=="},

{"objects":[{"id":"dd7337d0-797d-11ea-b521-59fdf02d9efc","type":"visualization","error":{"statusCode":409,"message":"version conflict, document already exists"}},{"id":"2b0af950-7a60-11ea-b521-59fdf02d9efc","type":"visualization","error":{"statusCode":409,"message":"version conflict, document already exists"}}

also it is giving me 400 Bad request when i dont have any issue with the json file uploaded but the dashboard is getting created successfully.

{"error":{"message":"Unsupported saved object type: 'undefined': Bad Request","statusCode":400,"error":"Bad Request"}}

what could be the reason? When i pass ndjson file as input to curl command it is still giving the same output with same errors.

There are two different APIs which can be used to upload dashboards:

It sounds like you are maybe mixing up the two of those? They are not compatible with each other. It is recommended to use the saved object api instead of the dashboard api.

The first error sounds like you are trying to duplicate a visualization but you aren't changing the id, causing it to collide with the already existing visualization. Try to generate new ids (they don't have to be uuids) for the visualizations as well when you are editing the file.

Hello Joe,

Im trying to use saved objects api via the dashboard file i got it from export saved object, however, it is throwing me 400 bad request

xyz@x:~/6may$ curl -v POST "localhost:5601/api/saved_objects/_bulk_create" -H 'kbn-xsrf: true' -d @dashboard.json

{"statusCode":400,"error":"Bad Request","message":"\"value\" must be an array","validation":{"source":"payload","keys":["value"]}}

Here is my dashboard file which is in json format.

Kibana Dashboard - github

Is the format in which im sending data needs change?

You definitely should get rid of line 35, but I'm not sure whether that's what's causing the import to fail.

What version of Kibana are you running?

I have removed 35th line and i still get the same issue.

I have tried the same on create saved objects (not bulk api) and i get this error

{"statusCode":400,"error":"Bad Request","message":"child \"attributes\" fails because [\"attributes\" is required].

I could not get it on how to modify my data in dashboard.json file so that it will give 200 ok status.

I'm using kibana 7.6v

Hello Joe, Could you pls guide on solving this issue

Could you share the exact call and request payload you are issuing with your non-bulk try?

curl -v POST "localhost:5601/api/saved_objects/dashboard" -H 'kbn-xsrf: true' -H 'Content-Type: application/x-ndjson' -d @kibana_dashboard_1.ndjson

kibana_dashboard.ndjson -> kibana_dashboard.ndjson

It is either giving me 400 bad request saying value should be an array or something with child attributes is what im getting.

Moving from: Doubt on how dashboard is selecting the index

@manojkrishna561994,
This doesn't look to me like the api I am seeing in docs.

I've tried:

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

where file.ndjson is export using Kibana's UI export functionality and it worked for me.

Please see for more details:
https://www.elastic.co/guide/en/kibana/7.7/saved-objects-api-import.html

Please note, this api is marked as experimental

This functionality is experimental and may be changed or removed completely in a future release. Elastic will take a best effort approach to fix any issues, but experimental features are not subject to the support SLA of official GA features.

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