Getting Data In

Log file in /etc/log is reindexed resulting in duplicate events

elusive
Splunk Employee
Splunk Employee

I have Splunk monitor a log directory in /etc/log. The logs in this directory are updated and rotated. However, Splunk keeps reindexing the files again and again from the beginning resulting in multiple duplicate events.

Tags (2)

elusive
Splunk Employee
Splunk Employee

The issue was related to having log in /etc directory. By default Splunk assumes files in /etc directory are configuration file and Splunk has a stanza by default that will index the whole file in $SPLUNK_HOME/etc/system/default/props.conf:

[source::(.../etc/...|....(config|conf|cfg|inii|cfg|emacs|ini|license|lng|plist|presets|properties|props|vim|wsdl))]
sourcetype=config_file
CHECK_METHOD = modtime

The workaround is to set priority higher than the default stanza using source stanza in props.conf (If you use host or sourcetype in the props.conf will not work), specify CHECK_METHOD so it will not use modtime.

For example:

[source::/etc/log/*] 
sourcetype=log_in_etc
CHECK_METHOD = endpoint_md5 
priority = 10 

Type of message to look for in splunkd.log is:

02-09-2011 21:15:17.993 INFO  WatchedFile - Will use tracking rule=modtime for file='/etc/log/test.log'.
02-09-2011 21:15:17.994 INFO  WatchedFile - Modtime is newer than stored, will reread file='/etc/log/test.log'.
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!

Make Your Machine Data AI-Ready in Splunk

Every team is getting ready for AI agents.    Watch On-Demand   In this Tech Talk, Splunk platform specialists ...

How to Break a Kubernetes Pod on Purpose and Let the AI Troubleshooting Agent Find ...

Let's say I've just rolled out a Kubernetes Deployment with a typo in the image tag. Nothing explodes. The pod ...

Splunk Add-on for Microsoft Windows 11.0.3: Parse Once, Search Faster

The updated Splunk Add-on for Microsoft Windows helps customers search Windows events faster by reducing ...