Splunk Search

Specifying Field w/ iplocation

mwollenweber
Engager

I'm trying to parse data that has multiple IP addresses. It's my understanding that iplocation tags any discovered IP with the relevant geolocation. My problem is that I'm unsure which IP address that that I'm getting results for. Is there a mechanism to specify the country of a given field such as ip1.Country or ip2.Country (assuming ip1 and ip2 are fields)?

Tags (1)
0 Karma

boris
Path Finder

Extending Iguinn's answer above:

Change 2 lines of code of this file: $SPLUNK_HOME/etc/apps/search/bin/iplocation.py

  for r in results:
        #if "_raw" in r: # OLD
        if "PUT-THE-FIELDNAME-HERE" in r: # NEW
            #raw = r["_raw"] # OLD
            raw = r["PUT-THE-FIELDNAME-HERE"] # NEW
0 Karma

lguinn2
Legend

The iplocation command is actually a Python script. So you could copy it and rename it to make your own customized version of the iplocation command. You will find the script at $SPLUNK_HOME/etc/apps/search/bin/iplocation.py

You will find instructions in the Splunk Developer manual under Custom Search Commands.

BTW, you could also change the iplocation command to use a different lookup technique; by default, iplocation does a lookup using http://api.hostip.info/get_html.php?ip=X where X is the ip address.

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...