Splunk Search

map command field not being evaluated

brdr
Contributor

I have an issue with a field within the map command not being evaluated appropriately. The scenario is this:

do something...
| table puser phost earliest latest
| map search="search index=winevents src_ip=$phost$ earliest=$earliest$ latest=$latest$ | eval puser=$puser$ | eval phost=$phost$ | head 1" maxsearches=100
| table puser phost

The issue is that 'phost' will display results only when the phost is an ip address. If the 'phost' value is a host name it will not display. Any idea why? NOTE: when I display the puser, phost via the first table command i get host name values. Only when map command runs do the host names not display in the second table command.

Tags (1)
0 Karma
1 Solution

woodcock
Esteemed Legend

You should probably change src_ip=$phost$ to either src=$phost$ or host=$phost$ or similar. It seems exceedingly unlikely that a field called src_ip would contain anything other than an IP address.

View solution in original post

woodcock
Esteemed Legend

You are either running in Fast Mode instead of Smart Mode OR you may be running into this problem, depending on how your field is created:

https://www.splunk.com/blog/2011/10/07/cannot-search-based-on-an-extracted-field.html

0 Karma

brdr
Contributor

Ok. i will take a look at the document. I have been running in smart mode. I have one more question if you don't mind sir. After the map command runs I table puser and phost. After that I need to perform a lookup of the puser to get the full name of the puser. And, then table puser, full name, phost. How can I carry the phost field into final table after the lookup?

 do something...
     | table puser phost earliest latest
     | map search="search index=winevents src_ip=$phost$ earliest=$earliest$ latest=$latest$ | eval puser=$puser$ | eval phost=$phost$ | head 1" maxsearches=100
     | table puser phost
      | lookup user_info account_name AS user OUTPUT ....
0 Karma

woodcock
Esteemed Legend

You should probably change src_ip=$phost$ to either src=$phost$ or host=$phost$ or similar. It seems exceedingly unlikely that a field called src_ip would contain anything other than an IP address.

brdr
Contributor

sorry that was a typo on my part. the field in the index is src. good catch. however, the problem still remains that phost is not displaying host names just IP. The work around is to table src, not phost.

thank you

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Catalog Is Now Generally Available on Splunk Cloud Platform

A Unified View of Your Data  Security logs, application events, business data, and historical telemetry often ...

Your Path to AgenticOps: AI Experiences for Every Splunk Practitioner

Your Path to AgenticOps: AI Experiences for Every Splunk Practitioner   Watch on demand us for a demo-driven ...