微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Kibana 使用 KQL 查询语法

1 KQL 提供了与或非 三种查询逻辑 and, or notg

1-1 与操作

logID:202108130823180101511900792F05F2EC and msg:request

1-2 或操作

name: "Jeff" or name: "Kitty"

1-3 非操作

not logID:202108130823180101511900792F05F2EC

not age >= 10

1-4 通配符操作

会从 msg字段中匹配到。result ,res, response,
所有以res前缀的都会匹配到。

msg:res*


2 加引号与不加引号

引号的使用

message:hello word

这个是搜索message中包含hello,或者包含world,或者两者都包含的情况。

如果只需要把整个hello word一起查询出来。则使用引号

message:"hello word"

3 常见的例子示范,优先级展示

response:200 or extension:PHP

匹配response列有200,或者extension列有PHP内容


response:200 and extension:PHP

匹配response列有200,并且extension列有PHP内容


response:(200 or 404)

匹配response列有200或者404内容


response:200 and (extension:PHP or extension:css)

匹配response列有200,并且extension列有PHP或者css的内容


response:200 and extension:PHP or extension:css

匹配response列有200并且extension列有PHP内容。或者extension列有css的内容

not response:200

匹配response列没有200的内容

response:200 and not (extension:PHP or extension:css)

匹配response列有200,并且extension列没有PHP、css的内容

tags:(success and info and security)

匹配tags列有success并且有info并且有security内容

4 支持对数字列使用数字范围比较

KQL支持对数字和日志列使用 < <= > >=

account_number >= 100 and items_sold <= 200

5 时间列范围

@timestamp < "2021-01-02T21:55:59"
 
@timestamp < "2021-01"
 
@timestamp < "2021"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐