Splunk Search

How to get to a working example of the Map Command?

muebel
SplunkTrust
SplunkTrust

I am trying:

name=foo minutesago=1 | head 1000 | dedup host | stats list(host) as list | map search="search host=$list$ | head 1"

the "name=foo minutesago=1" search will return a bunch of events from about 8 or 9 hosts. When I run the above search, I get 1 event back. I would expect 1 event from each host, per my understanding of the Map command.

Is there something here I am doing wrong? Could somebody provide a working example of Map in action? I suppose I might be passing the "$list$" variable incorrectly, but the documentation is a bit scant.

EDIT: Working search:

name=foo minutesago=1 | head 1000 | dedup host | map search="search host=$host$ | head 1"
Tags (2)
1 Solution

Stephen_Sorkin
Splunk Employee
Splunk Employee

My guess here is that the map command doesn't like the multivalued field that the stats command is outputting. What happens if you remove the stats command from your search?

View solution in original post

Stephen_Sorkin
Splunk Employee
Splunk Employee

My guess here is that the map command doesn't like the multivalued field that the stats command is outputting. What happens if you remove the stats command from your search?

muebel
SplunkTrust
SplunkTrust

ah... thats it. So the variable is all the values of a field in the collection of events that you pipe to map.

0 Karma
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 ...