问题描述
是否可以在Kibana中查询某个长度的值?
Is there a way to query for a value of a certain length in Kibana?
例如,给定以下两个KV对:
For example, given the following two KV pairs:
key: "some"
key: "something"
我想搜索key.length> 5并仅检索某物".
I would like to search for key.length > 5 and retrieve "something" only.
我看到的另一个选项是从Logstash添加标签,但是随后我将不得不重新加载数百GB.
The other option I see is to add a tag from logstash, but then I'll have to reload a couple hundred GB.
推荐答案
您可以在 Kibana 中使用脚本查询来执行此操作. Kibana中的脚本查询,有一个示例对于键长度大于5的脚本查询:
You can use script query to do that in Kibana. Script Query in Kibana, There is an example for script query with key's length more than 5:
{
"query": {
"filtered": {
"filter": {
"script": {
"script": "doc['key'].getValue().length() > 5"
}
}
}
}
}
此外,您还需要在 elasticsearch 中启用脚本搜索,还需要将以下配置添加到 elasticsearch.yml :
And also you need to enable script search in elasticsearch, you need to add the below config into elasticsearch.yml:
script.engine.groovy.inline.search: on
这篇关于Kibana查询字符串长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!