Get a Kibana Dashboard and some Visualizations from that Dashbor using API

Hello, I would like to get two dashboards... each dashboard has multiple visualizations and well I want to get some of those visualizations...

Using API (version 5.6), I could get the dashsboards:

curl -XGET localhost:5601/api/kibana/dashboards/export?dashboard=andc-KVStoreBoard1 -H 'kbn-xsrf: true' > andcDataStore.json

curl -XGET localhost:5601/api/kibana/dashboards/export?dashboard=andc-ProxyBoard1 -H 'kbn-xsrf: true' > andcProxy.json

and checking an extract of one of those json files, This is the output...:

{
"version": "5.6.4",
"objects": [
{
"id": "andc-KVHealthyValue",
"type": "visualization",
"version": 1,
"attributes": {
"title": "andc_KVHealthyValue",
"visState": "{"title":"andc_KVHealthyValue","type":"line","params":{"addTooltip":true,"addLegend":true,"legendPosition":"right","show
Circles":true,"interpolate":"linear","scale":"linear","drawLinesBetweenPoints":true,"radiusRatio":9,"times":,"addTimeMarker":false,"defaultY
Extents":false,"setYExtents":false,"grid":{"categoryLines":false,"style":{"color":"#eee"}},"categoryAxes":[{"id":"CategoryAxis-1","type":"
category","position":"bottom","show":true,"style":{},"scale":{"type":"linear"},"labels":{"show":true,"truncate":100},"title":{"text":"
@timestamp per minute"}}],"valueAxes":[{"id":"ValueAxis-1","name":"LeftAxis-1","type":"value","position":"left","show":true,"style":{},"
scale":{"type":"linear","mode":"normal","setYExtents":false,"defaultYExtents":false},"labels":{"show":true,"rotate":0,"filter":false,"trun
cate":100},"title":{"text":"HealthyValue"}}],"seriesParams":[{"show":"true","type":"line","mode":"stacked","data":{"label":"HealthyVal
ue","id":"1"},"valueAxis":"ValueAxis-1","drawLinesBetweenPoints":true,"showCircles":true,"interpolate":"linear","radiusRatio":9}],"type":"
line"},"aggs":[{"id":"1","enabled":true,"type":"min","schema":"metric","params":{"field":"health_val","customLabel":"HealthyValue"}},
{"id":"2","enabled":true,"type":"date_histogram","schema":"segment","params":{"field":"@timestamp","interval":"m","customInterval":"2
h","min_doc_count":1,"extended_bounds":{}}}],"listeners":{}}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{"index":"andc-kvpingstats-","query":{"query_string":{"query":"","analyze_wildcard":true}},"filter":}"
}
},
"col": 1,
"panelIndex": 4,
"row": 3,
"size_x": 3,
"size_y": 3
},
{
"id": "andc-KVRepNodes",
"type": "visualization",
"version": 1,
"attributes": {
"title": "andc_KVRepNodes",
"visState": "{"title":"andc_KVRepNodes","type":"pie","params":{"addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut"
:false},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{"customLabel":"RepNodes"}},{"id":"2","enabled":t
rue,"type":"terms","schema":"segment","params":{"field":"shard","size":100,"order":"desc","orderBy":"1"}},{"id":"3","enabled":true
,"type":"terms","schema":"segment","params":{"field":"resource","size":100,"order":"desc","orderBy":"1"}}],"listeners":{}}",
"uiStateJSON": "{}",
"description": "",
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{"index":"andc-kvrnopstats-","query":{"query_string":{"query":"","analyze_wildcard":true}},"filter":}"
}
},
"col": 4,
"panelIndex": 6,
"row": 3,
"size_x": 3,
"size_y": 3
},
{
"id": "andc-AdminEvents",
"type": "search",
"version": 3,
"attributes": {
"title": "andc_AdminEvents",
"description": "",
"hits": 0,
"columns": [
"planName",
"state",
"generalTask_NotStarted",
"migratePartition_Running"
],
"sort": [
"@timestamp",
"desc"
],
"version": 1,
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{"index":"andc-kvevents-","query":{"query_string":{"query":"type:kvPlanStats","analyze_wildcard":true}},"filter"
:[],"highlight":{"pre_tags":["@kibana-highlighted-field@"],"post_tags":["@/kibana-highlighted-field@"],"fields":{"
":{}},"require_field_match":f
alse,"fragment_size":2147483647}}"
}
},
"col": 7,
"columns": [
"planName",
"state",
"generalTask_NotStarted",
"migratePartition_Running"
],
"panelIndex": 12,
"row": 9,
"size_x": 6,
"size_y": 4,
"sort": [
"@timestamp",
"desc"
]
},
"col": 10,
"panelIndex": 14,
"row": 13,
"size_x": 3,
"size_y": 3
},

I just want to get some of those visualizations... not all of them... so this is the doubt:

How I could create a curl line to get some visualizations from a specific dashboard?

Thanks!

You can use the saved object API to get visualizations by id. 5.6 does not have any documentation on the saved object API but its there https://github.com/elastic/kibana/blob/5.6/src/server/saved_objects/routes/get.js#L4. You can look at the current saved object API documentation but things may have changed so you may be better off just looking at the source for how the API works

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