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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...