Splunk Search

How to get city or county names using latitude and longitude values in Splunk?

sravani27
Path Finder

Hi I have a CSV file with the list of latitudes and longitudes to display on the map.
I want to get the count of events and the name of the cities for each latitude and longitude.

the iplocation command works only when you have a field which has ipaddress.
but my dataset doesn't give me the ipaddress. I want to display the name of the city using the latitude and longitude values.
Please help.

0 Karma

MuS
Legend

Hi sravani27,

you can use the csv as a lookup http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Usefieldlookupstoaddinformationtoyourev... to get the latitude and longitude from this file. Once this is working set it up to be an automatic lookup, so Splunk will do it for you.
Next step is to use the geostats command http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Geostats by using this you can show the results on the map of your choice in Splunk.

Hope this helps ...

cheers, MuS

sravani27
Path Finder

Hi msu, thank you for the answer. I have already uploaded the csv and plotted the points on the map, and in a tabular format. But the issue here is I want to display the city names using the lat and lon values.
I am using the following query
| inputlookup my_location.csv| geostats latfield=latitude longfield=longitude count

my_location.csv file:
latitude longitude
51.41361111 -115.9377778
51.20333333 -120.7605556
58.89888889 -112.6469444
58.89888889 -112.6469444

0 Karma

MuS
Legend

So the question is: where is the city name coming from?

0 Karma

sravani27
Path Finder

I don't have the city name in my csv. I was hoping the latitude and longitude corrdinates would give me the city name

0 Karma

MuS
Legend

Maybe you need to change your source for this, have look at this free file https://www.maxmind.com/en/free-world-cities-database this can be used as csv lookup and provides Country, City, AccentCity, Region, Population, Latitude, Longitude

Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...