# Map IP Address to geolocation and use of the anomaly detector

**URL:** <https://discuss.elastic.co/t/map-ip-address-to-geolocation-and-use-of-the-anomaly-detector/270027>\
**Category:** Kibana\
**Created:** [April 13, 2021, 3:11pm UTC](https://discuss.elastic.co/t/map-ip-address-to-geolocation-and-use-of-the-anomaly-detector/270027 "2021-04-13T15:11:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vannessa\_Kemeni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vannessa_kemeni/32/83669_2.png) [@Vannessa\_Kemeni](https://discuss.elastic.co/u/Vannessa_Kemeni)\
**Post date:** [April 13, 2021, 3:11pm UTC](https://discuss.elastic.co/t/map-ip-address-to-geolocation-and-use-of-the-anomaly-detector/270027/1 "2021-04-13T15:11:40Z")

</div>

Hello everyone,  
i am using the wazuh software combined with ELK. I get some ip adress from Wazuh and i want to find the corresponding geolocation. How i can do that. Furthermore, i want to use the anomaly detector in order to find anormal behavior: e.g when a user has always an germany ip adress and suddenly has an french IP Adress. How i can realize it? Thank you

---

<div class="post-metadata">

**Author:** ![corey.robertson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corey.robertson/32/54611_2.png) [@corey.robertson](https://discuss.elastic.co/u/corey.robertson)\
**Post date:** [April 13, 2021, 3:52pm UTC](https://discuss.elastic.co/t/map-ip-address-to-geolocation-and-use-of-the-anomaly-detector/270027/2 "2021-04-13T15:52:32Z")

</div>

Hi @Vannessa_Kemeni

Elasticsearch includes a GeoIP processor that can be used when ingesting data to get the GeoLocation for an IP address. Read more about [GeoIP Processor](https://www.elastic.co/guide/en/elasticsearch/reference/7.12/geoip-processor.html#using-ingest-geoip)

For machine learning, I will direct you to the Machine Learning [Getting Started](https://www.elastic.co/guide/en/machine-learning/current/ml-getting-started.html) documentation. That should walk you through building your first machine learning job and you should be able to adapt that to your use case.

---

<div class="post-metadata">

**Author:** ![Vannessa\_Kemeni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vannessa_kemeni/32/83669_2.png) [@Vannessa\_Kemeni](https://discuss.elastic.co/u/Vannessa_Kemeni)\
**Post date:** [April 14, 2021, 7:48am UTC](https://discuss.elastic.co/t/map-ip-address-to-geolocation-and-use-of-the-anomaly-detector/270027/3 "2021-04-14T07:48:05Z")

</div>

Hi @corey.robertson ,  
i have read the documentation but i did not correctly understand it.  
I want to enrich some data, that are already in elastick search.  
when i use this command, what happens? Should I define the file for those i want to add this info or this command add automatically the geolocation to all data.  
PUT \_ingest/pipeline/geoip  
{  
"description" : "Add geoip info",  
"processors" : [  
{  
"geoip" : {  
"field" : "ip"  
}  
}  
]  
}

---

<div class="post-metadata">

**Author:** ![corey.robertson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/corey.robertson/32/54611_2.png) [@corey.robertson](https://discuss.elastic.co/u/corey.robertson)\
**Post date:** [April 14, 2021, 1:20pm UTC](https://discuss.elastic.co/t/map-ip-address-to-geolocation-and-use-of-the-anomaly-detector/270027/4 "2021-04-14T13:20:09Z")

</div>

@Vannessa_Kemeni

Here's a simple example of putting in a doc with an ip, and then reindexing it to a new index using the geoip processor, which will give you the geoip data

```auto
PUT my-index-00001/_doc/my_id
{
  "ip": "8.8.8.8"
}
GET my-index-00001/_doc/my_id
PUT _ingest/pipeline/geoip
{
  "description" : "Add geoip info",
  "processors" : [
    {
      "geoip" : {
        "field" : "ip"
      }
    }
  ]
}

POST _reindex
{
  "source": {
    "index": "my-index-00001"
  },
  "dest": {
    "index": "newindex",
    "pipeline": "geoip"
  }
}

GET newindex/_doc/my_id

```

---

<div class="post-metadata">

**Author:** ![Vannessa\_Kemeni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vannessa_kemeni/32/83669_2.png) [@Vannessa\_Kemeni](https://discuss.elastic.co/u/Vannessa_Kemeni)\
**Post date:** [April 16, 2021, 5:55pm UTC](https://discuss.elastic.co/t/map-ip-address-to-geolocation-and-use-of-the-anomaly-detector/270027/5 "2021-04-16T17:55:24Z")

</div>

Hi @corey.robertson ,  
i have noticed that the ip adresses are all private, I have made some researched in the forum for finding how to convert it into a location and i found that.

```auto
 if [client_address] =~ /^10\./ {
  mutate { replace => { "[geoip][timezone]" => "Pacific/Auckland" } }
  mutate { replace .....
} else {
  geoip {
    source => "client_address"
    target => "geoip"
    add_tag => ["nginx-geoip"]
  }
}

```

How i can use it? I don't really understant how that works. Can you please help me?

---

<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 14, 2021, 5:55pm UTC](https://discuss.elastic.co/t/map-ip-address-to-geolocation-and-use-of-the-anomaly-detector/270027/6 "2021-05-14T17:55:57Z")

</div>

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