Splunk Search

macro with regex

sumitnagal
Path Finder

I have use case where i have to pass host in macro argument. I also want to pass argument in regex way apart from * way. here is snippet
mymacro(host=*)
My host listing is in big number, more than 35 hosts example:- abc1, abc2 , abc11, abc21, abc22, abc24, abc25
Now I want to pass only 2 hosts only say abc11 and abc21 as argument, how can I do that. as abc

I know I can pass below
mymacro(host=abc1*)
or
mymacro(host=abc2*)
but how to pass both in same parameter?

Tags (3)
0 Karma

sumitnagal
Path Finder

is there any other option to solve this without specifying regex?
can we have some negate option handy, like abc11 and abc21 to be ignored, and rest all host comes.
in case we have multiple arguments say sourcetype with same regex pattern how it would look like?

mymacro(host=,source=)

0 Karma

sumitnagal
Path Finder

found the problem, it looks for double quote, adding that fix the problem

search xyz | regex host="$host$"

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

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