Archive

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

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

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.

Builder

Nice technique, thanks for posting.

0 Karma

SplunkTrust
SplunkTrust

Have you looked at fschange in props.conf?

---
If this reply helps you, an upvote would be appreciated.
0 Karma