安装Redis
yum install -y redis
配置Redis
vim /etc/redis.confbind 127.0.0.1 10.0.0.100port 6379
修改Filebeat配置
vim /etc/filebeat/filebeat.ymlfilebeat.inputs:- type: log enabled: true paths: - /var/log/nginx/access.log json.keys_under_root: true json.overwrite_keys: true tags: ["access"]- type: log enabled: true paths: - /var/log/nginx/error.log tags: ["error"]output.redis: hosts: ["10.0.0.100"] keys: - key: "nginx_access" when.contains: tags: "access" - key: "nginx_error" when.contains: tags: "error"
修改Logstash配置
vim /etc/logstash/conf.d/redis_nginx.confinput { redis { host => "10.0.0.100" port => "6379" db => "0" key => "nginx_access" data_type => "list" } redis { host => "10.0.0.100" port => "6379" db => "0" key => "nginx_error" data_type => "list" }}filter { mutate { convert => ["upstream_time", "float"] convert => ["request_time", "float"] }}output { stdout {} if "access" in [tags] { elasticsearch { hosts => "http://10.0.0.100:9200" manage_template => false index => "nginx_access-%{+yyyy.MM.dd}" } } if "error" in [tags] { elasticsearch { hosts => "http://10.0.0.100:9200" manage_template => false index => "nginx_error-%{+yyyy.MM.dd}" } }}