Splunk Search

Is it possible to append/concatenate regexes for one field check?

hexerino
Explorer

Currently I have a search as follows:

myFieldName="mySearchValue" | where match(path,`startOfPath`)
`startOfPath` expands to f.e. "^C\:\\\Windows\\\.*"

Some cases, however, I'd need to specify additional paths. In order to avoid to have a lot of repetition, my question was whether it was possible to use startOfPath + rest of path to validate the path.

As requested by mydog8it I'll elaborate with a concrete example of what I'm trying to accomplish.

macro 1 : filter_CLIENT_CONTROL
ThreatName="Client Control" | where match(SourcePath,`path_windows` + CustomRestOfPath)

macro 2 : path_windows
"^C\:\\\Windows\\\.*"

Whilst what I'm trying to accomplish is as follows for the filter_CLIENT_CONTROL macro:
ThreatName="Client Control" | where match(SourcePath,`path_windows` + ".*\\(COMPATTELRUNNER)\.EXE" ")

So in essence, the regex within the filter_CLIENT_CONTROL macro expands to ^C\:\\(WINDOWS)\\.*\\(COMPATTELRUNNER)\.EXE

Thank you

Tags (2)
0 Karma
1 Solution

hexerino
Explorer

After having provided information but not having received any feedback I solved the problem through an alternative approach.

View solution in original post

0 Karma

hexerino
Explorer

After having provided information but not having received any feedback I solved the problem through an alternative approach.

0 Karma

mydog8it
Builder

Can you provide example data and an example of how you would like it parsed? It sounds to me like you could just use two capture groups with the names "startOfPath" and another named "restOfPath".

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...