ElasticSearch可以使用ingest-geoip插件可以对ip进行地理位置分析
这个插件需要Maxmind的GeoLite2 City,GeoLite2国家和GeoLite2 ASN geoip2数据库。有关更多详细信息,请参见http://dev.maxmind.com/geoip/geoip2/geolite2/,现在需要注册才能下载!
该geoip处理器可以与Maxmind的其他GeoIP2数据库一起运行。必须将文件复制到ingest-geoip config目录中,目录位于$ES_CONFIG/ingest-geoip。
PUT _ingest/pipeline/geoip
{
"description" : "Add geoip info",
"processors" : [
{
"geoip" : {
"field" : "ip"
}
}
]
}
PUT my_index/_doc/my_id?pipeline=geoip
{
"ip": "8.8.8.8"
}
GET my_index/_doc/my_id
返回结果:
{
"found": true,
"_index": "my_index",
"_type": "_doc",
"_id": "my_id",
"_version": 1,
"_seq_no": 55,
"_primary_term": 1,
"_source": {
"ip": "8.8.8.8",
"geoip": {
"continent_name": "North America",
"country_iso_code": "US",
"location": { "lat": 37.751, "lon": -97.822 }
}
}
}