Getting Data In

How to forward entire .txt file in splunk from batch file

tbrown
Path Finder

I have a batch file that runs this:

 

break > D:\....\test.txt
break > D:\....\test2.txt
process1 >> D:\....\test.txt
process2 >> D:\....\test2.txt

 

Where each process appends text to test.txt. I included break at the beginning so that it will clear out the test.txt file and prevent it from becoming too large. 

I want all the contents of the .txt file to be forwarded as one event. As of right now, it's forwarding the events one line at a time of each test.txt. How can I forward these events as one single event with multiple lines?

They seem to be cut off due to line spacing/indentation so I want to turn that off as well.

Labels (3)
Tags (3)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Splunk can ingest files in batch mode, but that's a one-time process since Splunk will delete the file after it's been read.  There may be another option, though.  Consider adding these settings to the inputs.conf stanza for the file.

multiline_event_extra_waittime = true
time_before_close = 3600

These settings tell Splunk to wait until the file is closed before sending events and to not close the file until 3600 seconds (1 hour) after the last line is written to it.  Adjust the value of time_before_close to best suit how the file is written.

---
If this reply helps you, Karma would be appreciated.
0 Karma

anthonymelita
Contributor

I think you want to look at should_linemerge or creating a specific line_breaker options in props.conf

https://docs.splunk.com/Documentation/Splunk/8.0.4/Admin/Propsconf#Line_breaking

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...