nginx日志配置
log_format access_json '{"@timestamp":"$time_iso8601",' '"host":"$server_addr",' '"clientip":"$remote_addr",' '"size":$body_bytes_sent,' '"responsetime":$request_time,' '"upstreamtime":"$upstream_response_time",' '"upstreamhost":"$upstream_addr",' '"http_host":"$host",' '"uri":"$uri",' '"domain":"$host",' '"xff":"$http_x_forwarded_for",' '"referer":"$http_referer",' '"tcp_xff":"$proxy_protocol_addr",' '"http_user_agent":"$http_user_agent",' '"status":"$status"}'; access_log /var/log/nginx/access.log access_json;nginx配置使用json日志
filebeat
filebeat.inputs: - type: log enabled: true paths: - /var/log/nginx/access.log json.keys_under_root: true json.overwrite_keys: true tags: ["nginx-access"] - type: log enabled: true paths: - /var/log/nginx/error.log tags: ["nginx-error"] filebeat.config.modules: path: ${path.config}/modules.d/*.yml reload.enabled: false setup.ilm.enabled: false setup.template.enabled: false setup.template.name: "nginx" setup.template.pattern: "nginx-*" output.elasticsearch: hosts: ["172.16.50.207:9200","172.16.50.206:9200","172.16.50.207:9200"] indices: - index: "nginx-access-%{[agent.version]}-%{+yyyy.MM.dd}" when.contains: tags: "nginx-access" - index: "nginx-error-%{[agent.version]}-%{+yyyy.MM.dd}" when.contains: tags: "nginx-error" processors: - add_host_metadata: when.not.contains.tags: forwarded - add_cloud_metadata: ~ - add_docker_metadata: ~ - add_kubernetes_metadata: ~filebeat.yml
标签:log,tags,json,更新,access,nginx,host,EFK From: https://www.cnblogs.com/wxxjianchi/p/17930617.html