We would like to configure Logstash so that after it finishes processing an input file, the file is deleted. Is there a way to do this?
Thanks
We would like to configure Logstash so that after it finishes processing an input file, the file is deleted. Is there a way to do this?
Thanks
The stock file input doesn't have a "done" concept. It assumes that a file can always receive more data and never gives up the wait. What you can do is use the stdin input which reads until EOF and then terminates Logstash, after which you can delete the file (if Logstash terminated successfully). So, basically like this:
/path/to/logstash -f /path/to/configfile < logfile.log && rm logfile.log
Unfortunately, if Logstash is shut down while the file is being processed, it's not possible to restart Logstash and have it continue where it left off. If you need to be able to do that, consider using the file input and reading the sincedb files to figure out if Logstash has reached the end of the file. See Understanding sincedb files from Logstash file input for the format of those files.