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!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Your Voice Matters! Help Us Shape the New Splunk Lantern Experience

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Building Momentum: Splunk Developer Program at .conf25

At Splunk, developers are at the heart of innovation. That’s why this year at .conf25, we officially launched ...