使用logstash geoip筛选器能够将ip地址解析为更丰富的内容。html
结果相似于这样:git
"geoip": { "city_name": "Ürümqi", "continent_code": "AS", "country_code2": "CN", "country_code3": "CN", "country_name": "China", "dma_code": null, "ip": "x.x.x.95", "latitude": 43.801, "longitude": 87.6005, "postal_code": null, "region_name": "Xinjiang", "region_code": "65", "timezone": "Asia/Urumqi", "location": [ 87.6005 , 43.801 ] }
logstash 配置ide
filter{ geoip { source => "userip" database => "D:\elk\geoiplite2_city\GeoLite2-City.mmdb" } }
source 是IP字段
database 是使用的geolite2数据包,logstash默认自带的有一个包,可是是geolite的.dat包,geolite2是较新的格式。官网说明是只支持city城市包。
若是运行时报错,能够尝试更新geoip 插件后再试。
plugin update logstash-filter-geoip
geoip参数配置说明地址
https://www.elastic.co/guide/en/logstash/current/plugins-filters-geoip.htmlpost