# GeoIP2 plugin install throws an error on LS 5.0

**URL:** https://discuss.elastic.co/t/geoip2-plugin-install-throws-an-error-on-ls-5-0/64328
**Category:** Logstash
**Created:** [October 28, 2016, 10:12pm UTC](https://discuss.elastic.co/t/geoip2-plugin-install-throws-an-error-on-ls-5-0/64328 "2016-10-28T22:12:35Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![brian.jones](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@brian.jones](https://discuss.elastic.co/u/brian.jones)
#### Post date: [October 28, 2016, 10:12pm UTC](https://discuss.elastic.co/t/geoip2-plugin-install-throws-an-error-on-ls-5-0/64328/1 "2016-10-28T22:12:35Z")

</div>

After upgrading to Logstash 5 I am unable to install the geoip2 plugin (to handle IPv6 addresses). Any help would be great.

Error output:

```
    ./logstash-plugin install logstash-filter-geoip2 
Validating logstash-filter-geoip2
Installing logstash-filter-geoip2
Plugin version conflict, aborting
ERROR: Installation Aborted, message: Bundler could not find compatible versions for gem "logstash-core-plugin-api":
  In snapshot (Gemfile.lock):
    logstash-core-plugin-api (= 2.1.16)

  In Gemfile:
    logstash-devutils (~> 1.1) java depends on
      logstash-core-plugin-api (~> 2.0) java

    .... <truncated because of post limit, listed all installed plugins/versions>

    logstash-filter-geoip2 (>= 0) java depends on
      logstash-core-plugin-api (~> 1.0) java

    logstash-core-plugin-api (>= 0) java

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
```

---

<div class="post-metadata">

### Author: ![brian.jones](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@brian.jones](https://discuss.elastic.co/u/brian.jones)
#### Post date: [October 28, 2016, 10:36pm UTC](https://discuss.elastic.co/t/geoip2-plugin-install-throws-an-error-on-ls-5-0/64328/2 "2016-10-28T22:36:19Z")

</div>

After some research it seems the built-in geoip filter should support IPv6 (as noted here: [https://github.com/logstash-plugins/logstash-filter-geoip/issues/33](https://github.com/logstash-plugins/logstash-filter-geoip/issues/33)), however I am just getting a flood of log entries stating

`reason"=>"failed to parse [src_ip]", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"failed to parse ip [valid IPv6 address removed], not a valid ipv4 address (4 dots)"}}}}}`

If the newer geoip plugin supports IPv6 is there something I need to change in my config?

Here is the current geoip block in my filter config, and it seems to work fine on IPv4 addresses.

```
      geoip {
        add_tag => ["GeoIP"]
        database => "/etc/logstash/GeoLite2-City.mmdb" 
        source => "src_ip"
        }
```

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [November 3, 2016, 4:44am UTC](https://discuss.elastic.co/t/geoip2-plugin-install-throws-an-error-on-ls-5-0/64328/3 "2016-11-03T04:44:20Z")

</div>

That error message is from Elasticsearch, not Logstash. It looks like `src_ip` has been mapped as an IP address but doesn't contain an IP address. What's in the field?

---

<div class="post-metadata">

### Author: ![brian.jones](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@brian.jones](https://discuss.elastic.co/u/brian.jones)
#### Post date: [November 4, 2016, 6:39pm UTC](https://discuss.elastic.co/t/geoip2-plugin-install-throws-an-error-on-ls-5-0/64328/4 "2016-11-04T18:39:04Z")

</div>

Well, I'm not exactly sure what has happened, but I haven't seen this error in the logs over the last few days now. After a quick spot check it looks like logs with IPv6 address are getting geoip data added, even though it is just dead center on US without city/state, but that is Maxmind issue not Logstash.

However... Now I seem to be getting a java exception error if an IP field is blank.

`2016-10-31T10:41:21,060][ERROR][logstash.filters.geoip] IP Field contained invalid IP address or hostname {:exception=>java.net.UnknownHostException: -: Name or service not known,`

Any idea how i can "ignore" the null values before they are parsed by geoip? I figure some sort of "IF" statement, but I'm not sure how to filter on field = Null.

I will keep an eye on the logs to see if the parse issue comes back, but for now all seems ok.

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [November 5, 2016, 10:00am UTC](https://discuss.elastic.co/t/geoip2-plugin-install-throws-an-error-on-ls-5-0/64328/5 "2016-11-05T10:00:46Z")

</div>

It appears the field isn't null but contains a hyphen. In that case a conditional looks like this:

```nohighlight
if [name-of-ip-address-field] != "-" {
  geoip { ... }
}

```

You could also do a regexp match only use the geoip filter if the field in question looks like an IP address.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 4:30am UTC](https://discuss.elastic.co/t/geoip2-plugin-install-throws-an-error-on-ls-5-0/64328/6 "2017-07-06T04:30:55Z")

</div>


