Splunk Search

Is it possible to use regex in an inputs.conf monitor stanza?

edrivera3
Builder

Hi

Is it possible to do something like this:

[MONITOR:///some directory/WE\d{8}.log]

for indexing the following filenames:
WE93820493.log
WE37245293.log

I don't want to index the following filename: WE93820493corrupt.log and WE37245293test.log which are indexed with this inputs.conf:

[MONITOR:///some directory/WE*.log]

If it is not possible, is there a way to setup my stanza so I get a similar behavior?
Thanks,

1 Solution

mtranchita
Communicator

I think you can do what you want a number of ways but I would probably try using whitelist or blacklist in the monitor stanza.
I've listed the details on those from the reference the inputs.conf spec.

whitelist =
* If set, files from this input are monitored only if their path matches the specified regex.

blacklist =
* If set, files from this input are NOT monitored if their path matches the specified regex.

View solution in original post

woodcock
Esteemed Legend

The @mtranchita answer is the correct one but if you need to do something beyond RegEx, you can use this approach (but use additional logic):

https://answers.splunk.com/answers/309910/how-to-monitor-a-folder-for-newest-files-only-file.html

0 Karma

mtranchita
Communicator

I think you can do what you want a number of ways but I would probably try using whitelist or blacklist in the monitor stanza.
I've listed the details on those from the reference the inputs.conf spec.

whitelist =
* If set, files from this input are monitored only if their path matches the specified regex.

blacklist =
* If set, files from this input are NOT monitored if their path matches the specified regex.

edrivera3
Builder

I already know to use whitelist and blacklist, the problem is that those files are touched by different users and they don't use a standard way to name them. The only thing that I am sure is that they reserved this formal format: WEXXXXXXXX.log for official use. Thanks anyway for your response.

0 Karma
Get Updates on the Splunk Community!

Pro Tips for First-Time .conf Attendees: Advice from SplunkTrust

Heading to your first .Conf? You’re in for an unforgettable ride — learning, networking, swag collecting, ...

Raise Your Skills at the .conf25 Builder Bar: Your Splunk Developer Destination

Calling all Splunk developers, custom SPL builders, dashboarders, and Splunkbase app creators – the Builder ...

Hunt Smarter, Not Harder: Discover New SPL “Recipes” in Our Threat Hunting Webinar

Are you ready to take your threat hunting skills to the next level? As Splunk community members, you know the ...