繁体   English   中英

如何获取在 Kibana 中创建的索引列表?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM