Giter Club home page Giter Club logo

Comments (7)

childe avatar childe commented on August 21, 2024

http://dev.maxmind.com/geoip/geoip2/geolite2/
我在这里下载的免费版测试下来就可以. (不过我们公司是买的付费的 :)

你用的哪个版本? 完全的配置和报错发我一下吧.

from hangout.

keefeleen avatar keefeleen commented on August 21, 2024

使用 maxmind 的 City 库就正常,但是使用 Country 库就失败。

hangout 版本:hangout-0.1.8.2-ES2.3.5

相关配置如下:

- GeoIP2:
    source:  client_ip # required
    target: geoip # default geoip
    database: '/xxx/GeoLite2-Country.mmdb'

Debug 日志如下:

2016-11-30 16:14:01,510 DEBUG com.ctrip.ops.sysdev.filters.GeoIP2 pool-2-thread-1 java.lang.UnsupportedOperationException: Invalid attempt to open a GeoLite2-Country database using the city method
{request=xxx, source_host=xxx, method=GET, resp_len=21483, version=1.1, source_ip=223.xxx.xxx.xxx, tags=[geoipfail], resp_time=46974, @timestamp=2016-11-30T16:02:38.000+08:00, client_ip=183.xxx.xxx.xxx, fields={"severity":"3","pri-text":"local7.err","severity-text":"err","processid":"-","pri":"187","facility-text":"local7","program":"xxxxxx","facility":"23"}, status=200}

from hangout.

keefeleen avatar keefeleen commented on August 21, 2024

@childe 你好,我想询问一下关于这个 issue 现在的状况

from hangout.

childe avatar childe commented on August 21, 2024

@keefeleen 抱歉没注意到.

是我之前不知道对于country级别的数据库, 还有专门的country级别的API. 修复后的我已经上传到master上面了. 但当前是支持5.0ES的版本了. 你可能需要自己把master分支的filter/Geoip2.java代码考到你需要的版本下, 然后自己打包了.

如果你不知道怎么弄, 或者有什么问题, 联系我, 我打包好发你吧.

from hangout.

keefeleen avatar keefeleen commented on August 21, 2024

@childe 编译之后,country 级别数据库目前没有问题,但是用我们公司自己编译的数据库就有问题。

附件中是一个编译好用于测试的数据库(其中的 IP 列表比较少)。但是测试时 logstash 无报错(只不过因为数据问题解析出来字段 location 字段为空),如果使用 hangout 则仍然出现 geofail 的错误。

麻烦再看一下这个问题。谢谢!

test.mmdb.gz

from hangout.

childe avatar childe commented on August 21, 2024

@keefeleen logstash应该是一个第三方的插件吧,里面用到的读取mmdb库的ruby代码也是mmdb外的第三方作者写的, 根据IP定位到数据之后, 返回一个hash, 没有问题.

我这里用的是mmdb官方提供的库, https://github.com/maxmind/GeoIP2-java 调用的CountryResponse country(InetAddress ipAddress)和CityResponse city(InetAddress ipAddress) 这两个方法, 他们会先判断mmdb数据库中的metadata里面的database_type(具体说明参见https://maxmind.github.io/MaxMind-DB/, 你们应该也是按这个文档来制作的吧?)是不是包含 Country 或者 City. 看起来你们制作的库不包含, 所以报错了. 就把这个字符串改一下好了. 比如叫 "keefeleen Country db"

from hangout.

keefeleen avatar keefeleen commented on August 21, 2024

注释掉了 GeoIP2-java 中对应进行判断的代码,重新编译后目前看来没有问题。感觉这一个判断流程比较鸡肋。

感谢你的热心回复!

from hangout.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.