【问题标题】:Exported dashboard with Kibana API cannot be imported manually in Kibana UI使用 Kibana API 导出的仪表板无法在 Kibana UI 中手动导入
【发布时间】:2021-08-07 19:14:42
【问题描述】:

我可以使用此代码获取导出的仪表板。 API 来自 Kibana 文档: https://www.elastic.co/guide/en/kibana/master/dashboard-api-export.html

tmpdir = '/tmp/kibana/dashboards/'

if not os.path.exists(tmpdir):
    os.makedirs(tmpdir)

dashboard = requests.get('http://localhost:5601/api/kibana/dashboards/export?dashboard=d83837a0-7c21-11eb-9dad-4b1b4ebf9d55')

json_dashboard = dashboard.json()

dashboards_exported = []
dashboards_exported.append(json_dashboard)

with open(tmpdir+'Dash'+'.json', 'w') as outfile:
    json.dump(dashboards_exported, outfile, indent=2, sort_keys=True)

导出的仪表盘 json 文件如下: https://pastebin.com/YZTKJFn3

但是,当我想手动将其导入 Kibana UI 时,它会显示“未导入任何对象”。

当我从 Kibana UI 手动导出仪表板时,我得到以下 NDJSON 文件:https://pastebin.com/nuRFKjPx

您会注意到这两个文件略有不同并且格式不同(通过 API 的 JSON 和手动导出的 NDJSON)。 因此,我无法手动导入 API 生成的 JSON 文件。你知道为什么我导入第一个 JSON 文件时 Kibana 没有找到任何对象吗?

【问题讨论】:

  • 你运行的是什么版本的 Kibana / ES?在早期版本中,saved_objects API 和 GUI 中使用的格式之间存在细微但显着的格式差异
  • 我使用的是 Kibana 和 ES 的 7.10.1 版本

标签: python import export kibana dashboard


【解决方案1】:

有点晚了,但我认为你也应该导入 ndjson。 卷曲方式:

curl -X POST "{{ host_ip }}:{{ kibana_port }}/api/saved_objects/_import" -H "kbn-xsrf: true" --form file=@/tmp/kibana_stored_objects.ndjson

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-03
    • 2019-12-27
    • 1970-01-01
    • 2015-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-06
    相关资源
    最近更新 更多