Splunk Search

Does Splunk support rex in macros?

Splunk_God
Engager

I'm receiving the following error: Error in 'rex' command: Encountered the following error while compiling the regex ''(?P.(.{2': Regex: missing ). Am i doing something wrong? Here is the macro entry:

[Testing]
definition=rex field=file '(?P\.(.{2,4})$)' 
Tags (2)
1 Solution

MuS
Legend

Hi Splunk_God,

take a look at this macro which ships in Splunk 6.2:

[audit_rexsearch]
definition = rex "search='(?<search>.*?)', autojoin"

it uses " instead of your ' so changing the macro to

[Testing]
 definition=rex field=file "(?P\.(.{2,4})$)"

should do the trick.

Hope this helps ...

cheers, MuS

View solution in original post

MuS
Legend

Hi Splunk_God,

take a look at this macro which ships in Splunk 6.2:

[audit_rexsearch]
definition = rex "search='(?<search>.*?)', autojoin"

it uses " instead of your ' so changing the macro to

[Testing]
 definition=rex field=file "(?P\.(.{2,4})$)"

should do the trick.

Hope this helps ...

cheers, MuS

Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...