ELK - Logstash Nginx 로그 분석
logstash 프로필
# nginx_log.conf
input { file { type => "nginx_log" path => "/opt/nginx/logs/access.log" } } filter { if [ type ] == "nginx_log" { grok { match => { "message" => "%{NGINXACCESS}" } } if ([message] =~ "^*launcher*|^*favicon*" ) { drop {} } geoip { source => "remote_addr" target => "geoip" database => "/opt/logstash-2.0.0/conf/GeoLiteCity.dat" add_field => [ "[geoip][coordinates]" , "%{[geoip][longitude]}" ] add_field => [ "[geoip][coordinates]" , "%{[geoip][latitude]}" ] } mutate { convert => [ "[geoip][coordinates]" , "float" , "body_bytes_sent" , "float" , \ "body_bytes_sent.raw" , "float" ] } } } output { stdout { codec => rubydebug } elasticsearch { hosts => "192.168.0.100:9200" index => "ngx_log-%{+YYYY.MM}" } } NGINXACCESS 정의, patterns / nginx 파일 에 쓸 수 있 습 니 다.
NGUSERNAME [a-zA-Z\.\@\-\+_%]+NGUSER %{NGUSERNAME}NGINXACCESS %{IPORHOST:remote_addr} - - \[%{HTTPDATE:time_local}\] "%{WORD:method} %{URIPATHPARAM:request} HTTP/%{NUMBER:httpversion}" %{INT:status} %{INT:body_bytes_sent} %{QS:http_referer} %{QS:http_user_agent}
kibana 그래프 전시
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
logstash:grok 대신dissect로 성능을 향상시킵니다.파이프의 성능을 향상시키는 간단한 방법은 다른 필터로 대체할 수 있는지 확인하는 것이다grok.내가 계속 grok 로 대체하고 있는 필터는 dissect 필터다.grok과dissect 사이의 주요 차이점은 disse...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.