1. 程式人生 > 其它 >Kibana 使用 KQL 查詢語法

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"
我對任何唾手而得,快速,出自本能,即興,含混的事物沒有信心。我相信緩慢,平和,細水長流的力量,踏實,冷靜。我不相信缺乏自律精神和不自我建設,不努力,可以得到個人或集體的解放。