Splunk Search

Macro for Backslash Substitution

ephemeric
Contributor

I have a macro that adds a backslash to an existing backslash:

 

[backslash(1)]
args = arg
definition = replace("$arg$", "(\\\\)", "\\\\\\\\")
iseval = 1

 

 This works:

 

index=perfmon counter=`backslash(\processor)`

 

 This fails when the arg has spaces:

 

index=perfmon counter=`backslash("\processor time")`

 

The expanded search string:

 

(counter=\\processor index=perfmon time)

 

How do I get:

index=perfmon counter="\\processor time"

Oh please show me my stupidity as I have been banging my head on the desk for hours... 

Labels (1)
0 Karma
Get Updates on the Splunk Community!

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...