Knowledge Management

how to run macro arguments

nivethainspire_
Explorer

I created a macro with 3 arguments in UI as,

sample(3) with definition 'index=shapes sourcetype=rectangle |search $height$ $weight$ $mode$ |.....'

In my search i called the macro as below

sample($height$,$weight$,$mode$)|...|...

I get an error.Can anyone help with exact way of writing this scenario.

Tags (1)
0 Karma

woodcock
Esteemed Legend

You call it EITHER with literals (e.g. "32") or with existing field names (e.g. weight and mode), without the dollar-signs, like this (assuming that you are not running this inside of a dashboard panel where you are trying to access dashboard tokens):

Your base search here | `sample("32",weight,mode)`
0 Karma

koshyk
Super Champion

you need to call macro with back-ticks
`sample($height$,$weight$,$mode$)`

0 Karma

niketn
Legend

@nivethainspire_07... You will also have to pass parameters as string to macro...So the tokens should be inside double quotes:

`sample("$height$","$weight$","$mode$")`
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

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