Splunk Search

subsearch not returning IP address

Shivs2k
Explorer

I am trying to get a subsearch to return a single value which represents an IP address and I am getting an error "Error in 'eval' command: the number (ip address) is invalid"

 

eval a=
[ search index=pan sourcetype=pan:traffic dest_port=22
| stats count as c by src_ip
| sort - c
| head 1|return $src_ip]

 

any ideas?

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Add format clause

 

eval a=
[ search index=pan sourcetype=pan:traffic dest_port=22
| stats count as c by src_ip
| sort - c
| head 1|return $src_ip|format]

 

View solution in original post

ITWhisperer
SplunkTrust
SplunkTrust

Add format clause

 

eval a=
[ search index=pan sourcetype=pan:traffic dest_port=22
| stats count as c by src_ip
| sort - c
| head 1|return $src_ip|format]

 

Shivs2k
Explorer

thanks, this is cleaner than my solution!

0 Karma

Shivs2k
Explorer

ok I fixed it myself, you have to add quotes to it.

 

eval a=
[ search index=pan sourcetype=pan:traffic dest_port=22
| stats count as c by src_ip
| sort - c
| head 1|eval a="\""+src_ip+"\""|return $a]

0 Karma
Get Updates on the Splunk Community!

Splunk + ThousandEyes: Correlate frontend, app, and network data to troubleshoot ...

 Are you tired of troubleshooting delays caused by siloed frontend, application, and network data? We've got a ...

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

🔐 Trust at Every Hop: How mTLS in Splunk Enterprise 10.0 Makes Security Simpler

From Idea to Implementation: Why Splunk Built mTLS into Splunk Enterprise 10.0  mTLS wasn’t just a checkbox ...