0

As part of load testing, I have a couple of premade log files that simulate different scenarios.

I'm trying to use Logstash to send the content of 1 file, and resend it again in a loop every time it reaches EOF.

Is there a way for me to do that?

dorony
  • 1,008
  • 1
  • 14
  • 31

1 Answers1

0

better to use an input plugin, called file, so with this, Logstash will continuously read the log file from the beginning every time it reaches the end!

input {
  file {
    path => "/path/to/your/log/file.log"
    start_position => "beginning"
    sincedb_path => "/dev/null"
    mode => "read"
    file_completed_action => "delete"
    file_completed_log_path => "/path/to/completed/log/file.log"
    sincedb_clean_after => "0"
    close_older => "0"
    stat_interval => "1"
    discover_interval => "1"
  }
}

output {
  # Output configuration
}

update

by setting file_completed_action to "logstash_forward",your file will be sent again to Logstash when it reaches the end!

input {
  file {
    path => "/path/to/your/log/file.log"
    start_position => "beginning"
    sincedb_path => "/dev/null"
    mode => "read"
    file_completed_action => "logstash_forward"
    file_completed_log_path => "/path/to/completed/log/file.log"
    sincedb_clean_after => "0"
    close_older => "0"
    stat_interval => "1"
    discover_interval => "1"
  }
}
Freeman
  • 9,464
  • 7
  • 35
  • 58
  • unfortunately "log_and_continue" is not a valid value for file_completed_action, see: https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.html#plugins-inputs-file-file_completed_action – dorony Aug 02 '23 at 17:52
  • sorry, yes you are correct,I have updated the answer again, please check.by the way, what a beautiful child you have! May God bless you and your family, brother! – Freeman Aug 02 '23 at 20:11
  • "delete" will delete the file when reaching EOF, I'm looking for a way to resend it. and thanks! :) – dorony Aug 02 '23 at 22:50
  • ok you can use the `file_completed_action` option with the value "logstash_forward", check my answer again plz ! – Freeman Aug 03 '23 at 00:51
  • file_completed_action setting must use one of these values: ["delete", "log", "log_and_delete"] – dorony Aug 07 '23 at 18:52