logstash 運行


logstash啟動和配置

logstash linux下啟動如下

(守護進程)

./bin/logstash agent -f conf/paycenter.conf &

logstash配置

測試服務器的寫法:

業務日志文件格式如果是按天分隔:

gwp.eyimi.com_80_access_2017-07-18.log
gwp.eyimi.com_80_access_2017-07-19.log
gwp.eyimi.com_80_access_2017-07-19.log

那么在input里面使用日期格式

/data/other/nginxlogs/gwp.eyimi.com_80_access%{+YYYY.MM.dd}.log

如果是只有一個文件格式,直接使用文件的絕對路徑即可!

input {
     file {
        path => "/data/other/nginx_logs/gwp.eyimi.com_80_access_%{+YYYY.MM.dd}.log"
        codec => "json"
        type => "zuolinyoujia"
    }
    //可以寫多個文件,不過多個文件最終的type必須統一為一個!!!
//  file {
//        path => "/data/other/nginx_logs/nginx_error.log"
  //      codec => "json"
 //       type => "zuolinyoujia"
 //   }
}
output {
      redis {
                batch_count => 10
                data_type => "list"
                host => "10.0.9.43"
                port => 4501
                key => "%{type}"
                password => "chngalaxy2017!!!" #如果有安全認證,此項為密碼
                codec => "json"
        threads => 2
    }
    }
}

  

正式服務器的寫法

(正式服務器的機器資源在申請,先內網測試走通一下看看)

input {
     file {
        path => "/data/other/nginx_logs/gwp.eyimi.com_80_access.log"
        codec => "json"
        type => "zuolinyoujia"
    }
  file {
        path => "/data/other/nginx_logs/nginx_error.log"
        codec => "json"
        type => "zuolinyoujia"
    }
}
output {
      redis {
                batch_count => 10
                data_type => "list"
                host => "192.168.0.75"
                port => 4501
                key => "%{type}"
                password => "chngalaxylog2017good!!!" #如果有安全認證,此項為密碼
                codec => "json"
        threads => 2
    }
    }
}

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM