在運行Filebeat模塊以前:html
nginx模塊解析Nginx建立的access和error日誌nginx
當你運行模塊的時候,它在底層執行一些任務:ruby
這個模塊須要 ingest-user-agent 和 ingest-geoip 兩個Elasticsearch插件elasticsearch
你能夠在Elasticsearch主目錄下運行下列命令來安裝這些插件:spa
elasticsearch-plugin install ingest-geoip elasticsearch-plugin install ingest-user-agent
而後,重啓Elasticsearch插件
配置文件更名debug
cd /etc/filebeat/modules.d/
mv nginx.yml.disabled nginx.yml
修改nginx.yml文件rest
- module: nginx # Access logs access: enabled: true # Set custom paths for the log files. If left empty, # Filebeat will choose the paths depending on your OS. var.paths: ["/var/log/openresty/*.access.log"] # Error logs error: enabled: true # Set custom paths for the log files. If left empty, # Filebeat will choose the paths depending on your OS. var.paths: ["/var/log/openresty/*.error.log"]
而後重啓filebeat日誌
查看啓用或者禁用的模塊列表code
filebeat modules list
1.安裝插件
/usr/share/logstash/bin/logstash-plugin install logstash-filter-geoip
2.編輯配置文件/etc/logstash/conf.d/beats.conf
input { beats { port => 5044 } } filter { grok { match => { "message" => "%{HTTPDATE:timestamp}\|%{IP:remote_addr}\|%{IPORHOST:http_host}\|(?:%{DATA:http_x_forwarded_for}|-)\|%{DATA:request_method}\|%{DATA:request_uri}\|%{DATA:server_protocol}\|%{NUMBER:status}\|(?:%{NUMBER:body_bytes_sent}|-)\|(?:%{DATA:http_referer}|-)\|%{DATA:http_user_agent}\|(?:%{DATA:request_time}|-)\|"} } mutate { convert => ["status","integer"] convert => ["body_bytes_sent","integer"] convert => ["request_time","float"] } geoip { source=>"remote_addr" } date { match => [ "timestamp","dd/MMM/YYYY:HH:mm:ss Z"] } useragent { source=>"http_user_agent" } } output { elasticsearch { hosts => ["127.0.0.1:9200"] index => "nginx-%{+YYYY.MM.dd}" } stdout { codec => rubydebug }
而後啓動logstash
參考: