Getting Data In

How to use Splunk to monitor if a new file was added to a folder?

felixms
Explorer

As of today, is there a way to simply monitor a folder for new files created on it?

Right now, I am monitoring a folder via Data Input > Folder, and Splunk is listing the 5 lines of the single .txt file on that folder.
When, I just need to trigger an alert when a new file is added to that folder.

Tags (4)
0 Karma

renjith_nair
Legend

Splunk monitors files added to the directory automatically if you have configured monitor for a directory

Ref : http://docs.splunk.com/Documentation/Splunk/6.2.0/Data/Monitorfilesanddirectories

Whenever a new file is added, splunk creates a new source for that file unless you override the source parameter in the inputs.conf.

In that case, you can create an alert when a new source is created by comparing the count with previous one or looking for a specific event from the new file etc.

---
What goes around comes around. If it helps, hit it with Karma 🙂

felixms
Explorer

Thank you, Renjith.
I am a new user, so when you mentioned "you can create an alert when a new source is created by comparing the count with previous one or looking for a specific event from the new file etc."

Are these the steps to perform the above?
1. Go to Search and type the count comparison
2. Save this as an alert

Could you give a link or a sample syntax to do the comparison?

0 Karma

renjith_nair
Legend

Try this

|metadata type=sources|eval difference=now() - firstTime|fields source difference|where difference < 300

This will list the sources which have appeared in last 5 minutes. Schedule this for reasonable time window according to your requirement and adjust the difference accordingly. Try the above search without the where clause and test it

---
What goes around comes around. If it helps, hit it with Karma 🙂

felixms
Explorer

Thank you!

0 Karma
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...