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)

Nginx 日志文件下载

# 下载测试日志
[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

最新文章

  1. 如果你也会C#,那不妨了解下F#(4):了解函数及常用函数
  2. nginx安装及负载均衡配置
  3. HTML5画布实现方法:
  4. vsftpd.conf 怎么保存
  5. 字符串截取函数substr和substring的不同及其相关说明
  6. CImageList用法介绍
  7. 《web全栈工程师的自我修养》阅读笔记
  8. java项目中使用guava的工具包的心得
  9. pythonchallenge
  10. 分布式memcached-虚拟节点
  11. JUC虚假唤醒(六)
  12. vue父组件传值给字组件
  13. [Algorithm] Polynomial and FFT
  14. tf多线程读取数据
  15. 20155330 《网络攻防》 Exp4 恶意代码分析
  16. 使用cxf开发webservice接口
  17. python递归——汉诺塔
  18. 在Linux下配置.net网站
  19. mui.ajax()和asp.net sql服务器数据交互【2】json数组和封装
  20. 通过Collections将集合转换为线程安全类集合

热门文章

  1. v-model语法糖
  2. windows_myql 安装与卸载详细讲解,
  3. 参数模型检验过滤器 .NetCore版
  4. 处理K8S PVC删除后pod报错
  5. ubuntu14.04 LEMP(linux+nginx+mysql+php5)构建环境
  6. Springboot中mybatis控制台打印sql语句
  7. 键相同,比较两个map中的值是否相同
  8. 【题解】CF952F 2 + 2 != 4
  9. SpringBoot-Maven打包压缩瘦身
  10. Spark踩坑填坑-聚合函数-序列化异常