首页 > 其他 > 详细

ELk之使用kibana展示访问IP地图

时间:2018-06-18 20:17:34      阅读:506      评论:0      收藏:0      [点我收藏+]

  参考文档:http://blog.51cto.com/ls40905250/1915280

       https://blog.csdn.net/zsjwish/article/details/79792212

       https://blog.csdn.net/yanggd1987/article/details/50469113

  安装logstash的geoip插件,使logstash可以获取到国家及城市信息

yum install GeoIP-data -y

  修改原logstash配置文件

input{
    redis {
            host => "192.168.56.11"
            port => "6379"
            password => "123456"
            db => "3"
            data_type => "list"
            key => "system-log-5611"
        }
    redis {
            host => "192.168.56.11"
            port => "6379"
            password => "123456"
            db => "4"
            data_type => "list"
            key => "nginx-log"
        }
}

filter{
    if "nginx-log" in [tags] {
        json{
 	    source => "message"
 	}
        if [user_ua] != "-" {
        useragent {
         target => "agent"   #agent将过来出的user agent的信息配置到了单独的字段中
         source => "user_ua"   #这个表示对message里面的哪个字段进行分析
       }
      }
       if [user_ip] != "-" {
      geoip {
                        source => "user_ip"
                        target => "geoip"
                       # database => "/usr/share/GeoIP/GeoIPCity.dat"
                        add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
                        add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}"  ]
                }
                   mutate {
                        convert => [ "[geoip][coordinates]", "float"]
                }
     }
    }
}

output{
    if "nginx-log" in [tags]{
        elasticsearch{ 
	    hosts => ["192.168.56.11:9200"]
  	    index => "logstash-nginx-log-%{+YYYY.MM}"
        } 
        stdout{
            codec => rubydebug  
        }
    }
    if "system-log-5611" in [tags]{
        elasticsearch{ 
	    hosts => ["192.168.56.11:9200"]
  	    index => "system-log-5611-%{+YYYY.MM}"
        } 
    }
}

  PS:filter检测过滤如果是nginx日志并且user_ip不为空则调用geoip插件

     nginx的index设置需要在前面加logstash否则在kibana里面不识别

  通过ip获取到的信息如下

技术分享图片

  重启kibana然后进web界面进行设置

技术分享图片

技术分享图片

技术分享图片

  最终效果图

技术分享图片

 

ELk之使用kibana展示访问IP地图

原文:https://www.cnblogs.com/minseo/p/9195937.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!