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

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

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!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...