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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Thanks for the Memories: .conf26 Took Learning to New Heights

Thank you, Splunk Community, for making .conf26 in Denver one for the books. From packed Splunk University ...

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...

Splunk Auto Ingestion Parallel Pipeline Scaling

Why this feature matters Many Splunk environments experience ingestion pressure long before the host is fully ...