我想使用HTTP方法将新仪表板发布到我的本地Kibana实例,但是我找不到很多关于使用API来执行此操作的文档。
Kibana上有一个拉动请求,提到它正在添加此功能,但有关如何使用它的文档有限: https://github.com/elastic/kibana/pull/10858
我试图发布的仪表板示例:
{
"_id": "12345678-1234-1234-1234-1234567890op",
"_type": "dashboard",
"_source": {
"title": "my-app",
"hits": 0,
"description": "",
"panelsJSON": "",
"optionsJSON": "{\"darkTheme\":false}",
"uiStateJSON": "",
"version": 1,
"timeRestore": true,
"timeTo": "now/d",
"timeFrom": "now/d",
"refreshInterval": {
"display": "1 minute",
"pause": false,
"section": 2,
"value": 60000
},
"kibanaSavedObjectMeta": {
"searchSourceJSON": ""
}
}
}
答案 0 :(得分:4)
导出:
curl "localhost:5601/api/kibana/dashboards/export?dashboard=980381a0-a266-11e7-8f86-edd4a877426e" > export.json
{
"version": "7.0.0-alpha1",
"objects": [
{
"id": "12345678-1234-1234-1234-1234567890op",
"type": "dashboard",
"properties": {
"title": "my-app",
"hits": 0,
"description": "",
"panelsJSON": "",
"optionsJSON": "{\"darkTheme\":false}",
"uiStateJSON": "",
"version": 1,
"timeRestore": true,
"timeTo": "now/d",
"timeFrom": "now/d",
"refreshInterval": {
"display": "1 minute",
"pause": false,
"section": 2,
"value": 60000
}
}
}
]
}
导入:
从仪表板导出API发布响应。
curl -X POST -H "Content-Type: application/json" -H "kbn-xsrf: true" -d @export.json http://localhost:5601/api/kibana/dashboards/import
答案 1 :(得分:0)
@Tyler的答案非常有效。 我试图将仪表板从Java应用程序导入到Kibana。以下在6.3.0上运行良好:
HttpPost request = new HttpPost("http://localhost:5601/api/kibana/dashboards/import");
StringEntity params =new StringEntity(IMPORTED_JSON_STRING);
request.addHeader("content-type", "application/json");
request.addHeader("kbn-xsrf", "true");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);