[英]How to get the list of indices created in Kibana?
我能夠從 Elasticsearch 中檢索索引,並以 Java 編程方式在 Kibana 中注冊相應的索引模式。 現在我想獲取已在 Kibana 中創建的索引模式列表,以便我可以將其與 Elasticsearch 中的索引列表進行交叉檢查,以免在 Kibana 中再次創建它們。
是否有從 Kibana 獲取索引模式列表的 API?
--
用於從 Elasticsearch 獲取索引列表的 API: http://{hostname}:{port}/_aliases
在 Kibana 中創建索引模式的 API: http://{hostname}:{port}/{kibana instance Id}/index-pattern/{index pattern title}
使用下一個查詢:GET /.kibana/index-pattern/_search
此查詢有效(來自 kibana 開發控制台):
GET .kibana/_search?size=10000
{
"_source": ["index-pattern.title"],
"query": {
"term": {
"type": "index-pattern"
}
}
}
適用於 kibana 7.x:
curl -s 'http://192.168.100.100:5601/api/saved_objects/_find?fields=title&fields=type&per_page=10000&type=index-pattern'
# Use jq to get the index-pattern name:
curl -s 'http://192.168.100.100:5601/api/saved_objects/_find?fields=title&fields=type&per_page=10000&type=index-pattern' | jq '.saved_objects[].attributes.title'
"service01"
"service02"
"service03"
curl -XDELETE -H 'kbn-xsrf: ""' 'http://192.168.100.100:5601/api/saved_objects/index-pattern/970070d0-f252-11ea-b492-31ec85db4535'
-H 'kbn-xsrf: ""'
必須設置,否則 API 會報錯{"statusCode":400,"error":"Bad Request","message":"Request must contain a kbn-xsrf header."}
使用jq -r
獲取沒有 qoute 的值。
恐怕目前它仍然不可用,您可以在其中使用 api 來公開在Kibana
中創建的所有索引。
但請記住,只有您已經在 ES 中創建了索引,您才能在Kibana
中創建索引。 所以也許你可以考慮檢查你的 ES 索引是否已經有一個現有的索引,如果沒有創建索引。 如果您的索引列表中不存在該索引,您可以在哪里確定,這意味着您無法繼續在Kibana
中創建索引。
您可以從 API 中列出它們:
GET _cat/indices/.marvel* GET _cat/indices/.kibana
我查看了 Kibana(5.5 版)控制台,通過執行此查詢可以獲得相同的結果
curl -X POST -H 'Content-Type: application/json' \
-d '{"query":{"match_all":{}},"size":10000}' \
http://$ES_HOST/.kibana/index-pattern/_search/\?stored_fields\=""
請注意,如下向上述 url 發出 GET 請求也會返回字段,但僅限於 10 個。
curl http://$ES_HOST/.kibana/index-pattern/_search/\?stored_fields\=""
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.