[英]ElasticSearch - Kibana - Not able to get Index Pattern with Python
[英]Convert Kibana query (create index pattern) to Python request
我正在尝试将此 Kibana 查询转换为 Python:
PUT /.kibana/_doc/index-pattern:tempindex
{
"type": "index-pattern",
"index-pattern": {
"title": "tempindex",
"timeFieldName": "sendTime"
}
}
这是我到目前为止所拥有的:
HEADERS = {
'Content-Type': 'application/json'
}
uri = "http://localhost:5601/_doc/index-pattern:tempindex"
query = json.dumps({
"type": "index-pattern",
"index-pattern": {
"title": "tempindex",
"timeFieldName": "sendTime"
}
})
r = requests.put(uri, headers=HEADERS, data=query).json()
print(r)
但它给了我
{'statusCode': 404, 'error': 'Not Found', 'message': 'Not Found'}
我究竟做错了什么?
PS:Elastic 和 Kibana 服务器都是本地的(Windows 10)。
似乎只需更改uri
就可以了:
uri = "http://localhost:9200/.kibana/_doc/index-pattern:tempindex"
但是我不确定HEADERS
,因为正如lupanoide指出的那样, kbn-xsrf: true
应该存在,但无论哪种方式它似乎都在工作,显然结果是相同的(我还没有发现差异) .
编辑:正如文档所说:
kbn-xsrf: true
默认情况下,您必须对所有 API 调用使用
kbn-xsrf
,但以下情况除外:API 端点使用
GET
或HEAD
操作
使用server.xsrf.whitelist设置将路径列入白名单
使用server.xsrf.disableProtection
设置禁用 XSRF 保护
所以我认为它应该存在。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.