logstash 使用筆記

logstash-2.3.4的logstash.conf的配置文件

一、監控日誌文件,匹配關鍵字,輸出到指定文件/發送郵件。

input {

    file {

    path => ["你的日誌文件"]

    }

}

filter {

    if ([message] !~ "你的匹配關鍵字") {

        drop {}

    }

   if [loglevel] == "debug" {

    drop {

    percentage => 40

    }

   }

}

output {

    stdout{

        codec => rubydebug

    }

   if ([message] =~ "你的匹配關鍵字") {

         file {

           path => "輸出到指定文件"

          }

        email {

                to => "接收郵箱"

                from => "發送者"

                address => "smtp.sina.cn"

             domain => "sina.cn"

                username => "你的用戶名"

                password => "你的密碼"

                subject => "error log"

                body => "%{path}"

                htmlbody => "%{message}"

          }

    }

}

啓動:logstash-2.3.4\bin>logstash -f  ../conf/logstash.conf

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章