使用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