Kibana 地标图可视化
ElasticSearch 可以使用 ingest-geoip 插件可以在 Kibana 上对 IP 进行地理位置分析,
这个插件需要 Maxmind 的 GeoLite2 City,GeoLite2 国家和 GeoLite2 ASN geoip2 数据库。有关更多详细信息,请参见
http://dev.maxmind.com/geoip/geoip2/geolite2/,现在需要注册才能下载!
安装 GeoIP
# 将软件包在 logstash 目录中解压
[root@web01 logstash]# rz ingest-geoip-6.6.0.zip
[root@web01 logstash]# unzip ingest-geoip-6.6.0.zip
# 下载地址
http://geolite.maxmind.com/download/geoip/database/
# 外网太慢,我存了一份
https://www.linuxyz.top/download/software/ELK/ingest-geoip-6.6.0.zip
配置 Logstash
配置时需要注意,索引名称必须是 "logstash-*" 才可以使用 GeoIP ,生成坐标图
[root@web01 conf.d]# cat geotest.conf
input {
file {
path => "/var/log/nginx/access.log"
type => "nginx_access_log"
start_position => "end"
codec => "json"
}
}
filter {
json {
source => "message"
remove_field => ["message"]
}
geoip {
source => "clientip"
target => "geoip"
database => "/etc/logstash/config/GeoLite2-City.mmdb"
add_field => [ "[geoip][coordinates]", "%{[geoip][longitude]}" ]
add_field => [ "[geoip][coordinates]", "%{[geoip][latitude]}" ]
}
mutate {
convert => [ "[geoip][coordinates]", "float"]
}
}
output {
elasticsearch {
hosts => ["10.0.0.121:9200"]
index => "logstash-%{type}-%{+YYYY.MM.dd}"
}
}
模拟生成数据(多 Client IP)
# 下载测试日志
[root@blog ELK]# wget https://www.linuxyz.top/download/software/test_log/access_test.log
[root@blog ELK]# cat access_test.log >> /var/log/nginx/access.log
记录成长过程