Getting Data In

Can I monitor files on a schedule instead of a continuously monitoring a file?

leo_wang
Path Finder

Due to the question I posted before :
http://answers.splunk.com/answers/291010/how-to-merge-a-multiline-event-correctly.html

I have an idea that if the Splunk could monitor the files on a schedule (not always continuously monitoring the log), I could avoid the multiline event problem.
Because our batch jobs will finish after AM 3:00, the logs will not grow after this time and the multiline event will group correctly.

Tags (2)
0 Karma

potnuru
Path Finder

Hi @leo_wang , Did you solve the multi-line event problem for Batch Scripts? If Yes, Please share the solution it with me.

0 Karma

woodcock
Esteemed Legend

The way to do this is to setup 2 cron jobs on your forwarder as the same user as Splunk was installed (is running) that do this:

30 4 * * * /usr/bin/mv $SPLUNK_HOME/etc/apps/myapp/inputs.conf $SPLUNK_HOME/etc/apps/myapp/inputs.off && $SPLUNK_HOME/bin/splunk restart
30 3 * * * /usr/bin/mv $SPLUNK_HOME/etc/apps/myapp/inputs.off $SPLUNK_HOME/etc/apps/myapp/inputs.conf && $SPLUNK_HOME/bin/splunk restart

Or, if you dislike being so drastic, you can create a soft link to the directory where the files are, update your inputs.conf to point to the soft link and then do a similar thing but create and remove the soft link. Then you will not have to restart Splunk each time.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Perhaps you could modify the batch job to move your log files into a monitored directory when the job completes. Alternatively, you could create a second batch job to move the logs every morning.

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

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...