Is it possible to have ip addresses in a search resolved to a host name and displayed in the results rather then the ip address. My search is:
source="udp:514" "dst=192.168." | stats count by dst | sort -count limit=10
This gives me the top ten hit ip addresses. I would like to see the host name rather than (or as well as) the ip address. Can this be done as part of the search string?
There is no need to create a lookup table as long as the nameserver holds those records. Just use the following after your example search:
<search> | lookup dnslookup clientip as dst OUTPUT clienthost as DST_RESOLVED
If performance is an issue with dnslookup, which can happen when you have many distinct ips being returned by your search, you may want to populate your own lookup and refresh it nightly when there is less demand for resources. Here's a search I run nightly against a week of Windows security event log data to get the ips of machines that have been logged into, but you could substitute your own search for a list of ips to look up:
sourcetype=wineventlog:security EventCode=4768 NOT src_ip="::1"
| eval ip=replace(src_ip,"[f:]","")
| dedup ip
| lookup dnslookup clientip as ip OUTPUTNEW clienthost as hostname
| table ip, hostname
| outputlookup ip2host.csv
this query has worked for me "lookup dnslookup clientip as lsp_rro OUTPUT clienthost as hops" when trying to make a human readable LSP path. We use /etc/hosts for the IP to hostname lookup, you can also use a DNS server to fill this requirement such as BIND9, MS Server or dnsmasq to name a few.
There is no need to create a lookup table as long as the nameserver holds those records. Just use the following after your example search:
<search> | lookup dnslookup clientip as dst OUTPUT clienthost as DST_RESOLVED
perfect, thanks for this solution - works perfectly
You should click "Accept" to close the question.
Yes. But you will need a lookup table that matches the IP address to the host name.
Depending on the apps you have installed, you may find that this lookup table already exists. If it does already exist you will find it in the lookup folder, and it will automatically populate a field in which case you simply need to add the field to your stats. The name of the field escapes me.
You answered at the same time I did. Besides, if they are already there...
Actually, the answers entries I linked to are for using an external command that performs the lookup on the fly and responds with the results.
Read the following:
http://answers.splunk.com/answers/8051/dns-lookup-via-splunk
and
http://answers.splunk.com/answers/103154/dns-lookup-for-ip-address-in-log-meesage
Those should do it for you!
The transforms.conf files did the trick and with a little manipulation of the search I have the results I wanted.
Thanks.