码迷,mamicode.com
首页 > 数据库 > 详细

收集Nginx-access,Nginx-error日志

时间:2019-05-12 17:10:27      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:search   收集   index   usr   ruby   grep -v   mob   conf   stash   

1.配置Logstash

[root@Logstash logstash]# vim /usr/local/logstash/config/nginx_log.conf

input {

  beats {

    port => "5044"

     }

}

filter {

    if [type] == "nginx"{

    grok {

    match => { "message" => "%{NGINXACCESS}" }

 

  }

 

  }

 

  date {

    match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]

    target => ["datetime"]

  }

  geoip {

    source => "clientip"

  }

 

}

output {

     if [fields][logsource] == "nginx_access"{

     elasticsearch {

      hosts => ["192.168.200.130:9200"]

      index => "nginx_access"

     }

  }

   if [fields][logsource] == "nginx_error"{

     elasticsearch {

      hosts => ["192.168.200.130:9200"]

      index => "nginx_error"

     }

  }

 

  stdout { codec => rubydebug }

}

 

2.配置filebeat:

[root@mobanji filebeat]# egrep -v "#|^$" filebeat.yml

filebeat.prospectors:

- type: log

  fields:

    logsource: nginx_access

    log_type: access_log

  paths:

    - /usr/local/nginx/logs/access.log

- type: log

  fields:

    logsource: nginx_error

    log_type: error_log

  paths:

    - /usr/local/nginx/logs/error.log

output.logstash:

  hosts: ["192.168.200.131:5044"]

收集Nginx-access,Nginx-error日志

标签:search   收集   index   usr   ruby   grep -v   mob   conf   stash   

原文地址:https://www.cnblogs.com/momenglin/p/10852746.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!