如何使用RESTful API在Kibana中导入/导出仪表板 [英] How to import/export a dashboard in Kibana using a RESTful API

查看:238
本文介绍了如何使用RESTful API在Kibana中导入/导出仪表板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用HTTP方法将新的仪表板发布到我的本地Kibana实例,但是我找不到太多有关使用API​​进行此操作的文档.

I would like to use a HTTP method to post new dashboards to my local Kibana instance, but I couldn't find much documentation on using an API to do this.

在Kibana上有一个请求请求,提到它正在添加此功能,但是关于如何使用它的文档有限: https://github.com/elastic/kibana/pull/10858

There was a pull request on Kibana that mentioned it was adding this functionality, but there was limited documentation on how to use it: https://github.com/elastic/kibana/pull/10858

我要发布的仪表板示例:

An example of a dashboard I'm trying to post:

{ "_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": "" } } }

{ "_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": "" } } }

推荐答案

导出:

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的响应.

POST the response from the dashboard export API.

curl -X POST -H "Content-Type: application/json" -H "kbn-xsrf: true" -d @export.json http://localhost:5601/api/kibana/dashboards/import

这篇关于如何使用RESTful API在Kibana中导入/导出仪表板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆