麋鹿收集nginx日志并用高德地图展示出IP

  

(一)测试的环境

agentd: 192.168.180.22

ES: 192.168.180.23

kibana: 192.168.180.23

采用的拓扑:logstash——祝辞ES -祝辞kibana


(二)实施步骤:

,,(1)logstsh具体配置:

1,配置nginx日志格式,采用log_format格式:

log_format , main ,“remote_addr 美元;作用;remote_user 美元;[time_local美元],“美元请求”,“   ,,,,,,,,,,,,,,,,,,,,,”status  body_bytes_sent 美元;“http_referer美元”,“   ,,,,,,,,,,,,,,,,,,,,,”“http_user_agent美元”,“http_x_forwarded_for美元”;

2,在logstash服务器下载IP地址归类查询库

[root@localhost 配置]#,cd /usr/地方/logstash/config/緍oot@localhost 配置】#,wget  http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb。   广州

3,配置logstash客户端

[root@localhost 配置]#,vim /usr/地方/logstash/config/nginx-access.conf    input  {   ,,,,,,,file  {   ,,,,,,,,,,,,,,,path =祝辞,/opt/access.log”   ,,,,,,,,,,,,,,,type =祝辞,“nginx”   ,,,,,,,,,,,,,,,start_position =祝辞,“开始”   ,,,,,,,,,,,,,}   ,,,,,,,,,,,}   filter  {   ,,,,,,,,,grok  {   ,,,,,,,,,,,,,,,match =祝辞,{,“消息”=祝辞,“% {IPORHOST: remote_addr},安康;作用;\ [% {HTTPDATE: time_local} \], \ " %{我们   理查德·道金斯:方法},% {}URIPATHPARAM:请求,HTTP/%{号码:httpversion} \”, % {INT:地位}% {INT: body_bytes_sent}, %   {QS: http_referer}, % {QS: http_user_agent}”   ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,}   ,,,,,,,,,,,,,,,,,,,,}   ,geoip  {   ,,,,source =祝辞,“remote_addr”   ,,,,target =祝辞,“geoip”   ,,,,database =祝辞,“/usr/地方/logstash/config/GeoLite2-City.mmdb”   ,,,,add_field =祝辞,(“[geoip](坐标)”,“% {[geoip][经度]}”)   ,,,,add_field =祝辞,(“[geoip](坐标)”,“% {[geoip](纬度)}”)   ,,,,,,,,,,,,,,,}   ,,}   ,,   output  {   ,,,,,,,,,,,,,,,elasticsearch  {   ,,,,,,,,,,,,,,,,,,,,,,,hosts =祝辞,(“192.168.180.23:9200”)   ,,,,,,,,,,,,,,,,,,,,,,,manage_template =祝辞,true ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,   ,,,,,,,,,,,,,,,,,,,,,,,index =祝辞,“logstash-map - % {+ YYYY-MM}”,,,,,,,,,,,,,,,,,,,,,,,,,   ,,,,,,,,,,,,,,,,,,,,,,,,,},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null   null

麋鹿收集nginx日志并用高德地图展示出IP