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!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...