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!

How to Monitor Google Kubernetes Engine (GKE)

We’ve looked at how to integrate Kubernetes environments with Splunk Observability Cloud, but what about ...

Index This | How can you make 45 using only 4?

October 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Splunk Education Goes to Washington | Splunk GovSummit 2024

If you’re in the Washington, D.C. area, this is your opportunity to take your career and Splunk skills to the ...