Splunk Search

How to re-index a file everyday, even when the file is not updated?

Venkat_16
Contributor

Hey All,

We have a file which has the version number of an application in the below format :
version = 4.0

The requirement is to get notified when the version field gets updated. In order to do so, the file has to be re-indexed very often. Also note that file size is very small. We are looking for a solution where we can get notified when the version field gets changed. We do not want to restart the Splunk server as we can re-index a file after deleting the fish bucket.

Kindly suggest any solution which matches above constraints

0 Karma

lguinn2
Legend

I would not use monitor or fschange. I would write a script like this

#!//bin/sh
# gets basic file info 
ls -l fileABC
# reads fileABC and writes it to stdout
cat fileABC

Set this up as a scripted input and have it run once per day, or as often as you like. In the example below, the script runs at 5 minutes past the hour, every hour.
Here is an example of inputs.conf within an app - the script is in the bin directory of the same app

[script://./bin/my_script.sh]
interval=5 * * * *
sourcetype = fileChecker

Here is a search that you can use for an alert. The search should probably be scheduled to run every hour at 10 minutes past the hour, and the alert condition should be "number of results > 0"

sourcetype=fileChecker | head 2 
| stats dc(version) as distinctVersions list(version) 
| where distinctVersions > 1

Also, this solution doesn't require resetting the fishbucket or using CRCsalt tricks or restarting anything, ever.

_smp_
Builder

Nice technique, thanks for posting.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Have you looked at fschange in props.conf?

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Why You Can't Miss .conf25: Unleashing the Power of Agentic AI with Splunk & Cisco

The Defining Technology Movement of Our Lifetime The advent of agentic AI is arguably the defining technology ...

Deep Dive into Federated Analytics: Unlocking the Full Power of Your Security Data

In today’s complex digital landscape, security teams face increasing pressure to protect sprawling data across ...

Your summer travels continue with new course releases

Summer in the Northern hemisphere is in full swing, and is often a time to travel and explore. If your summer ...