dorony
dorony

Reputation: 1072

Logstash how to send data from a file in a loop?

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?

Upvotes: 0

Views: 163

Answers (1)

Freeman
Freeman

Reputation: 12708

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"
  }
}

Upvotes: 0

Related Questions