# If IP results in \_geoip\_lookup\_failure is it possible to fill geoip-related vields with a custom value?

**URL:** <https://discuss.elastic.co/t/if-ip-results-in-geoip-lookup-failure-is-it-possible-to-fill-geoip-related-vields-with-a-custom-value/329144>\
**Category:** Logstash\
**Created:** [April 3, 2023, 2:42am UTC](https://discuss.elastic.co/t/if-ip-results-in-geoip-lookup-failure-is-it-possible-to-fill-geoip-related-vields-with-a-custom-value/329144 "2023-04-03T02:42:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![roman-tasi](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@roman-tasi](https://discuss.elastic.co/u/roman-tasi)\
**Post date:** [April 3, 2023, 2:42am UTC](https://discuss.elastic.co/t/if-ip-results-in-geoip-lookup-failure-is-it-possible-to-fill-geoip-related-vields-with-a-custom-value/329144/1 "2023-04-03T02:42:05Z")

</div>

Basically if the IP cannot be found in the database, I want to fill the `geoip.city_name`, `geoip.region_name`, and `geoip.country_name` with a custom value like "PRIVATE ADDRESS" or "IP NOT IN DATABASE" or something similar... is this possible?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 3, 2023, 3:40am UTC](https://discuss.elastic.co/t/if-ip-results-in-geoip-lookup-failure-is-it-possible-to-fill-geoip-related-vields-with-a-custom-value/329144/2 "2023-04-03T03:40:18Z")

</div>

> [@roman-tasi](#):
>
> is this possible?

You cannot do that using the geoip filter, but, if, after being processed by the geoip filter it has a \_geoip\_lookup\_failure tag then you could try

```
if "_geoip_lookup_failure" in [tags] {
    mutate {
        add_field => {
            "[geoip][city_name] => "Here?"
            "[geoip][region_name]" => "West side? East side?"
            "[geoip][country_name]" => "Whatever you want!"
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![roman-tasi](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@roman-tasi](https://discuss.elastic.co/u/roman-tasi)\
**Post date:** [April 3, 2023, 8:09am UTC](https://discuss.elastic.co/t/if-ip-results-in-geoip-lookup-failure-is-it-possible-to-fill-geoip-related-vields-with-a-custom-value/329144/3 "2023-04-03T08:09:00Z")

</div>

> [@Badger](#):
>
> ```auto
> if "_geoip_lookup_failure" in [tags] {
> mutate {
> add_field => {
> "[geoip][city_name] => "Here?"
> "[geoip][region_name]" => "West side? East side?"
> "[geoip][country_name]" => "Whatever you want!"
> }
> }
> }
> 
> ```

I'm trying this but Logstash is giving a syntax error and then failing. Can you fix it?

```auto
            if [log][file][path]=="/opt/zimbra/log/audit.log"{
              grok {
                  break_on_match => false
                  match => {
                      "message" => [
                           "cmd=%{WORD:cmd}",
                           "account=(?<account>[^;]*);",
                           "DeviceType=%{WORD:deviceType}",
                           "\[ip=%{IPV4:src-ip}",
                           "oip=%{IPV4:src-ip}",
                           "protocol=%{WORD:protocol}"
                      ]
                  }
              }
              geoip {
                  source => "[src-ip]"
              }
              if "_geoip_lookup_failure" in [tags] {
                 mutate {
                    add_field => {
                        "[geoip][city_name] => "PRIVATE IP"
                        "[geoip][region_name]" => "PRIVATE IP"
                        "[geoip][country_name]" => "PRIVATE IP"
                    }
                 }
              }
           }

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [April 3, 2023, 4:57pm UTC](https://discuss.elastic.co/t/if-ip-results-in-geoip-lookup-failure-is-it-possible-to-fill-geoip-related-vields-with-a-custom-value/329144/4 "2023-04-03T16:57:54Z")

</div>

> [@roman-tasi](#):
>
> `"[geoip][city_name] => "PRIVATE IP"`

You are missing the closing quote on the field name.

---

<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:** [May 1, 2023, 4:58pm UTC](https://discuss.elastic.co/t/if-ip-results-in-geoip-lookup-failure-is-it-possible-to-fill-geoip-related-vields-with-a-custom-value/329144/5 "2023-05-01T16:58:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
