Splunk Search

Having trouble passing values in a macro to collect command.

ddelmont
Explorer

Splunkers,

I sure hope this is just user error and I am myopic today! 

Have a simple macro:

 

collectevents(2)
args=index_parm,testmode_parm
| addinfo | collect index=$index_parm$ testmode=$testmode_parm$ source=mysource 

 

These both work:

 

`collectevents("Indexname",0)`
`collectecents("Indexname","False")`

 

But these don't work:

 

stuff....
|eval index_parm="Indexname"
|eval testmode_parm=0
`collectevents(index_parm,testmode_parm)`

 

 When ever I pass a variable I get: 

Error in 'SearchProcessor': Invalid option value. Expecting a 'boolean' for option 'testmode'.  Instead got 'testmode_parm'.

It only complains about the testmode, but it's not passing the index_parm string correctly either.   If I don't pass or remove testmode_parm, I stop getting an error but nothing shows up in the index.  Crtl+Shift+E show index=index_parm.  It's like the substitution is just not taking place.

Any ideas?  Thank you.

Labels (1)
Tags (3)
0 Karma
1 Solution

ddelmont
Explorer
0 Karma

ddelmont
Explorer

Thank you Murphy.  Should have posted this sooner.  Found a solution at:

https://community.splunk.com/t5/Knowledge-Management/collect-index-quot-based-on-values-quot/td-p/47... 

Tags (2)
0 Karma

to4kawa
Ultra Champion

is string or number in this case, I guess.

0 Karma
Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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