Getting Data In

What is incorrect with my regular expression in my inputs.conf file?

twmjim
New Member

Hello,
I'm trying to pull in a logfile that is named different on each workstation, using a regular expression in the inputs.conf file.

The filename is written to each workstation as follows:

filename format:

`    `*logfile*     (static text)
`    `*computer#*      -> three digit number, with leading zeros
`    `*.txt*

for example:.

`    `Computer#1 - logfile001.txt
`    `Computer#2 - logfile002.txt
`    `...
`    `Computer #20 - logfile020.txt

etc..

I attempted to create a regular expression to distribute out to each workstation so that Splunk would read in whatever the filename that is located on the terminal, but the file fails to load.

`    `**[monitor://C:\logs\logfile0(01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20).txt]**

I cannot use a wildcard in the monitor line, such as *logfile**.txt* because files are rolled over each day with a same filename with the addition of a timestamp (i.e. logfile01_2017-02-05.txt) and I don't want to re-read the archived data into the index.

Does anyone have a suggestion on what is incorrect with the expression that would cause the file not to be loaded?

Any advice would be appreciated. Thank you in advance!

0 Karma
1 Solution

s2_splunk
Splunk Employee
Splunk Employee

I would try

[monitor://C:\logs\logfile*]
whitelist = .*\.txt$

This monitors the directory for files starting with "logfile", but only whitelists files that end with .txt (anchored to end of file name). That should preclude any files that have been rotated by adding a timestamp from being picked up.
Adjust the whitelist RegEx if you need to ensure the three-digit number is there (add \d{3})

View solution in original post

0 Karma

somesoni2
Revered Legend

Try like this

[monitor://C:\logs\logfile*.txt]
index=foo
sourcetype=bar
whitelist=logfile\d+\.txt$
0 Karma

twmjim
New Member

Thank you for your response; it worked out great.

0 Karma

s2_splunk
Splunk Employee
Splunk Employee

I would try

[monitor://C:\logs\logfile*]
whitelist = .*\.txt$

This monitors the directory for files starting with "logfile", but only whitelists files that end with .txt (anchored to end of file name). That should preclude any files that have been rotated by adding a timestamp from being picked up.
Adjust the whitelist RegEx if you need to ensure the three-digit number is there (add \d{3})

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...