2017-02-28 64 views
0

所以我寫了一個過濾器,刪除具有某一領域具有null值的任何事件:Logstash過濾器,下降事件時的東西是空

filter { 
    if[type] == "flow" and [packet_source][ip] == "" { 
      drop { } 
    } 
} 

但是,這是行不通的。有誰知道爲什麼?參數的名稱是正確的

Logstash版本5.2

+0

這個答案可能會幫助:HTTP://計算器.com/a/28959437/4604579 – Val

回答

4

你的過濾器檢查[packet_source][ip] == ""存在且空。

不知道什麼[type] == "flow"是的,但我想你想

filter { 
    if[type] == "flow" and ("" not in [packet_source][ip]) { 
    drop { } 
    } 
} 

您還可以使用!("" in [packet_source][ip])!([packet_source][ip] == "")

然而,每個文檔,還有目前沒有辦法,沒有按一個字段進行區分不存在與只是虛假的領域。

您可以參考:https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html

+0

謝謝!我對我看到的其他一些論壇帖子感到困惑,但是你說的那裏有效。 '[type] ==「flow」' [Packetbeat](https://www.elastic.co/products/beats/packetbeat)收集的netflow數據 – BenjaFriend

1

添加到@ cattastrophe的回答,試試這個還有:

if "flow" in [type] and "" in [packet_source][ip]{  
    drop { }   
} 

if[type] == "flow" and [packet_source][ip] == 'null'{ <-- please try with double quotes around null as well 
     drop { }   
}