Getting Data In

Handle log rolling and index yesterday's log file

shabamichae
Path Finder

we have a scenario where we roll logs everyday. we want Splunk to index log file for yesterday only. We don't want to ingest todays log files. what specific setting d i require in  my input. Conf file to only ingest yesterdays data. 

ignoreOlderThan = 1d  also ingests todays logfiles which i do not want to.

 
 
0 Karma
1 Solution

PickleRick
SplunkTrust
SplunkTrust

I think I'd try to simply use logrotate or some custom script to move the log from yesterday to another directory from which they would normally be ingested  with monitor input.

View solution in original post

livehybrid
SplunkTrust
SplunkTrust

Hi @shabamichae 

What do your monitor stanzas currently look like for monitoring these files? Do the logs roll to a "logName.log.1" format (.1 being yesterday)?

If so. you may be able to update your existing monitor stanzas to add a whitelist (see https://docs.splunk.com/Documentation/Splunk/9.4.0/Data/Monitorfilesanddirectorieswithinputs.conf#:~...)

whitelist = <regular expression>	If set, the Splunk platform monitors files whose names match the specified regular expression.	

## inputs.conf ##
[monitor:///var/log/*]
index=syslog
sourcetype=example
..etc..
whitelist = .*\.1$

Also check out https://docs.splunk.com/Documentation/Splunk/latest/Data/Specifyinputpathswithwildcards

Please let me know how you get on and consider adding karma to this or any other answer if it has helped.
Regards

Will

 

0 Karma

shabamichae
Path Finder

Yes i do understand would require some kind of regex , but My issue is how do i wrrite the regex  to match the date , do i need to configure a dat.xml file to read the current date 

server.log.20250303.1
server.log.20250303.10
server.log.20250303.11
server.log.20250303.12
server.log.20250303.13
server.log.20250303.14
server.log.20250303.15

0 Karma

PickleRick
SplunkTrust
SplunkTrust

You simply can't. A regex matches a pattern. The pattern is static. It can contain some "recursive" elements but you can't put something like "today's date" as part of the pattern.

shabamichae
Path Finder

Hi @livehybrid 
Thanks for your response, below is a sample log file names

server.log.20250303.1
server.log.20250303.10
server.log.20250303.11
server.log.20250303.12
server.log.20250303.13
server.log.20250303.14
server.log.20250303.15

0 Karma

PickleRick
SplunkTrust
SplunkTrust

I think I'd try to simply use logrotate or some custom script to move the log from yesterday to another directory from which they would normally be ingested  with monitor input.

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 ...