Splunk Search

Optimize Regex

secphilomath1
Explorer

I am getting an error when using the following regex

(?<=on\s)(.*)(?=\sby Firewall Settings)

The error is "Error in 'rex' command: regex="(?<=on\s)(.*)(?<HostName>.*)(?=\sby Firewall Settings)" has exceeded configured match_limit, consider raising the value in limits.conf."

Is there a better way to do this,  I am trying to find all text between "on " and " by Firewall Settings.  It works in regex101.com, but I get that error in Splunk.

 

TIA!

 

Labels (2)
Tags (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

It would help to have a sample (sanitized) event to work with.

Avoid lookbehind and lookahead in Splunk.  They're costly and rarely necessary.  Try

on\s(?<HostName>\S*)\sby Firewall Settings
---
If this reply helps you, Karma would be appreciated.

View solution in original post

0 Karma

secphilomath1
Explorer

Good to know, thanks, works perfectly.

 

richgalloway
SplunkTrust
SplunkTrust

It would help to have a sample (sanitized) event to work with.

Avoid lookbehind and lookahead in Splunk.  They're costly and rarely necessary.  Try

on\s(?<HostName>\S*)\sby Firewall Settings
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

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

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...