我正在尝试将索引模式、可视化和仪表板从一个 Kibana 移动到另一个。它们在不同的 docker 中运行,监听不同的端口。在 saved_objects API 中有导入和导出。天真地假设我尝试了下面的代码export
可以消耗产生的东西:import
import requests as req
header = {'Content-Type': 'application/json', 'kbn-xsrf': 'true'}
request_json_index_pattern = '''
{
"type": "index-pattern"
}
'''
index_patterns = req.post(kibana_host+':5601/api/saved_objects/_export',
data=request_json_index_pattern,
headers = header,
auth = (elastic_user, elastic_password))
res = req.post(kibana_host+':5602/api/saved_objects/_import',
data=index_patterns.content,
headers = header,
auth = (elastic_user, elastic_password))
print(res.content)
但我得到的只是
{'statusCode': 415, 'error': 'Unsupported Media Type', 'message': 'Unsupported Media Type'}
所有这一切,尽管这index_patterns.content
是一个格式良好的 ndjson——我可以用ndjson.loads
.
我错过了什么?
(顺便说一句,我的源 Kibana 实例是 7.3.1 而目标是 7.4.0。这可能是问题吗?)