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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...