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!

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...