2016-05-24 4 views
0

のための単一のイベントをserachするには、私が達成しようとするものですが、私はここでは、ルータやスイッチからsyslogを収集しようとする一つのデバイスLOGSTASH - どのようにここでパターン

I 05/23/16 11:50:14 ports: port 14 is now off-line 
I 05/23/16 11:49:38 ports: port 14 is now on-line 
W 05/23/16 11:49:36 ports: port 14 PD Invalid Signature indication. 
I 05/23/16 11:49:35 ports: port 14 is Blocked by STP 
I 05/23/16 11:49:32 ports: port 14 is now off-line 
I 05/23/16 11:49:26 ip: VLAN101: network enabled on 10.101.0.130 
I 05/23/16 11:49:26 ip: VLAN101: changing IP address to 10.101.0.130 

からの例である私が今やりたいすべて「今はオフライン」のような文字列をキャッチしてエミールアラートを送信し、2番目の部分はすべてのログを簡単に通過するためにキバナを使用します。私はLogstash、Elasticsearch、Kibanaを手に入れました。すべてのログが通ってきています。私はちょうど、私が必要とする文字列をキャッチし、それをマークし、それに基づいて何らかのアクションを行う必要があるので、

ログは、例えば、複数のデバイス、さまざまな種類から流れるれる電子メールに

を送って私はすべてのsyslog作品ブレーキを持っていますかピースで? ログを検索する機能はありますか?

input { 
    udp { 
     type => "syslog" 
     port => 514 
    } 
    } 
filter { 
    if [type] == "syslog" { 
     **check if the single sting(or strings from dictionary) exist in this message** 
     **if yes, mark it, tag it if not just send the raw event to elasticsearch** 
    } 
} 

output { 
    elasticsearch { **send all logs** 
    } 
    **if the event needs attention send alert** { 
    email { 
     from => "[email protected]" 
     subject => "%{tagged_event}" 
     to => "[email protected]" 
     via => "mail" 
     body => "Alert something something: %{@message}" 
    } 
    } 
} 

答えて

0

一致するものの複雑さによっては、いくつかの方法があります。

in演算子:

if [type] == "syslog" { 
    if "is now off-line" in [message] or "some other thing" in [message] { 
     mutate { add_tag => [ "alertNeeded" ] } 
    } 
} 

正規表現=~演算子:

if [type] == "syslog" { 
    if [message] =~ /is now (off-line|on-line)/ { 
     mutate { add_tag => [ "alertNeeded" ] } 
    } 
} 

そして出力部に

if "alertNeeded" in [tags] { 
    email { ... } 
} 
関連する問題