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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...