Splunk Search

Search Marcro - Sending Results to Macro Variable.

chrisboy68
Contributor

Hi, I'm having the hardest time trying to figure out how to pass an event field into a variable argument to be used in a macro. 

This is my test_macro accepting one argument. 

 

| eval $sub_arg$=subject | sendemail to="myemail address" format="html" server="myserver address" use_tls=1 subject= $sub_arg$

 

 

Test SPL :

|  makeresults 
|  eval subject = "Test Subject"
 `test_macro(subject)`

 

The subject comes into / validated to "subject" and not "Test Subject". What am I doing wrong?

Thank you!

Chris 

Labels (1)
Tags (1)
0 Karma

chrisboy68
Contributor

Neither work." test_macro($subject$)`", sends the literal string "$subject$" and the other fails to run.

0 Karma

me74fhfd
Path Finder

alternatively:

| makeresults
| eval subject = "Test Subject"
| `test_macro($subject$)`

0 Karma

me74fhfd
Path Finder

Can you please try this:

| makeresults
| `test_macro(subject="Test Subject")`

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...