我有一个领域在Kibana发现具有以下值-
D_00122 - A - 14
D_00133A - 15
D_00145 - 18
D_00167 - B - 18
D_00182A - 19
D_00121 - A - 13
D_0011 - 18
字符串
我想正确的KQL只选择具有以下格式的值-
- 以'D_'开头,然后是数字(数字后面没有字符)。
- 一个空间
- 连字符
- 一个空间
- 然后是数字
最终输出-
D_00145 - 18
D_0011 - 18
型
我试过下面的查询,但它不工作-
data_no.keyword : D_* AND NOT data_no.keyword : 'D_*A - *'
型
2条答案
按热度按时间xmjla07d1#
正则表达式:“D_\d+ - \d+”将只捕获您想要捕获的两行。
“D_”与字符“D_”匹配(区分大小写)
“\d”匹配数字(相当于[0-9])
“+”在一次和无限次之间匹配上一个令牌,尽可能多的次数,根据需要回馈(贪婪)
“-“与字符“-”匹配(区分大小写)
参见:https://regex101.com/r/SJQ6ou/1
并使用此网站学习和测试regex
bpzcxfmw2#
我建议你使用an ingest pipeline来检查这个条件,并为此创建一个新的字段。下面是你如何做到这一点:
的数据
来自Kibana Discover的结果:
的