Ввод файла Logstash не выводит событие после изменения файла

Я пытаюсь читать из файла и выводить каждое событие на консоль (или в файл). Я хочу иметь возможность добавлять в файл, чтобы Logstash подхватил его и повторил конвейер. Однако Logstash, кажется, читает и выполняет конвейер только один раз, даже если видит, что файл изменился.

Я разрабатываю на OS X Yosemite.

Вот моя конфигурация LogStash

input {  
      file {
          path => "/Users/Justin/logstash-1.5.2/testFile"
          sincedb_path => "/Users/Justin/logstash-1.5.2/.sincedb"
          start_position => "beginning"
      }
}


output {  
   stdout {

   }
}

Вот журнал (также пробовал с sudo, не повезло):

    Justins-MacBook-Pro-2:logstash-1.5.2 justin$ bin/logstash agent --debug -vf myConfig
Reading config file {:file=>"logstash/agent.rb", :level=>:debug, :line=>"295", :method=>"local_config"}
Compiled pipeline code:
        @inputs = []
        @filters = []
        @outputs = []
        @periodic_flushers = []
        @shutdown_flushers = []

          @input_file_1 = plugin("input", "file", LogStash::Util.hash_merge_many({ "path" => ("/Users/Justin/logstash-1.5.2/testFile") }, { "sincedb_path" => ("/Users/Justin/logstash-1.5.2/.sincedb") }, { "start_position" => ("beginning") }))

          @inputs << @input_file_1

          @output_stdout_2 = plugin("output", "stdout")

          @outputs << @output_stdout_2

  def filter_func(event)
    events = [event]
    @logger.debug? && @logger.debug("filter received", :event => event.to_hash)
    events
  end
  def output_func(event)
    @logger.debug? && @logger.debug("output received", :event => event.to_hash)
    @output_stdout_2.handle(event)

  end {:level=>:debug, :file=>"logstash/pipeline.rb", :line=>"28", 
    :method=>"initialize"}
    Plugin not defined in namespace, checking for plugin file {:type=>"input", :name=>"file", :path=>"logstash/inputs/file", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
    Plugin not defined in namespace, checking for plugin file {:type=>"codec", :name=>"plain", :path=>"logstash/codecs/plain", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
    config LogStash::Codecs::Plain/@charset = "UTF-8" {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@path = ["/Users/Justin/logstash-1.5.2/testFile"] {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@sincedb_path = "/Users/Justin/logstash-1.5.2/.sincedb" {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@start_position = "beginning" {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@debug = false {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@codec = <LogStash::Codecs::Plain charset=>"UTF-8"> {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@add_field = {} {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@stat_interval = 1 {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@discover_interval = 15 {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@sincedb_write_interval = 15 {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Inputs::File/@delimiter = "\n" {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    Plugin not defined in namespace, checking for plugin file {:type=>"output", :name=>"stdout", :path=>"logstash/outputs/stdout", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
    Plugin not defined in namespace, checking for plugin file {:type=>"codec", :name=>"line", :path=>"logstash/codecs/line", :level=>:debug, :file=>"logstash/plugin.rb", :line=>"133", :method=>"lookup"}
    config LogStash::Codecs::Line/@charset = "UTF-8" {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Outputs::Stdout/@type = "" {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Outputs::Stdout/@tags = [] {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Outputs::Stdout/@exclude_tags = [] {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Outputs::Stdout/@codec = <LogStash::Codecs::Line charset=>"UTF-8"> {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    config LogStash::Outputs::Stdout/@workers = 1 {:level=>:debug, :file=>"logstash/config/mixin.rb", :line=>"112", :method=>"config_init"}
    Registering file input {:path=>["/Users/Justin/logstash-1.5.2/testFile"], :level=>:info, :file=>"logstash/inputs/file.rb", :line=>"76", :method=>"register"}
    Pipeline started {:level=>:info, :file=>"logstash/pipeline.rb", :line=>"86", :method=>"run"}
    Logstash startup completed
    _sincedb_open: reading from /Users/Justin/logstash-1.5.2/.sincedb {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"220", :method=>"_sincedb_open"}
    _sincedb_open: setting ["11809694", 1, 4] to 1089 {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"224", :method=>"_sincedb_open"}
    _sincedb_open: setting ["11850406", 1, 4] to 15 {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"224", :method=>"_sincedb_open"}
    _discover_file_glob: /Users/Justin/logstash-1.5.2/testFile: glob is: ["/Users/Justin/logstash-1.5.2/testFile"] {:level=>:debug, :file=>"filewatch/watch.rb", :line=>"132", :method=>"_discover_file"}
    _discover_file: /Users/Justin/logstash-1.5.2/testFile: new: /Users/Justin/logstash-1.5.2/testFile (exclude is []) {:level=>:debug, :file=>"filewatch/watch.rb", :line=>"141", :method=>"_discover_file"}
    _open_file: /Users/Justin/logstash-1.5.2/testFile: opening {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"119", :method=>"_open_file"}
    /Users/Justin/logstash-1.5.2/testFile: initial create, no sincedb, seeking to beginning of file {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"156", :method=>"_open_file"}
    Received line {:path=>"/Users/Justin/logstash-1.5.2/testFile", :text=>"Hello World", :level=>:debug, :file=>"logstash/inputs/file.rb", :line=>"137", :method=>"run"}
    Received line {:path=>"/Users/Justin/logstash-1.5.2/testFile", :text=>"Testing", :level=>:debug, :file=>"logstash/inputs/file.rb", :line=>"137", :method=>"run"}
    output received {:event=>{"message"=>"Hello World", "@version"=>"1", "@timestamp"=>"2015-07-21T22:58:13.460Z", "host"=>"Justins-MacBook-Pro-2.local", "path"=>"/Users/Justin/logstash-1.5.2/testFile"}, :level=>:debug, :file=>"(eval)", :line=>"21", :method=>"output_func"}
    writing sincedb (delta since last write = 1437519493) {:level=>:debug, :file=>"filewatch/tail.rb", :line=>"196", :method=>"_read_file"}2015-07-21T22:58:13.460Z Justins-MacBook-Pro-2.local Hello World

    output received {:event=>{"message"=>"Testing", "@version"=>"1", "@timestamp"=>"2015-07-21T22:58:13.464Z", "host"=>"Justins-MacBook-Pro-2.local", "path"=>"/Users/Justin/logstash-1.5.2/testFile"}, :level=>:debug, :file=>"(eval)", :line=>"21", :method=>"output_func"}
    2015-07-21T22:58:13.464Z Justins-MacBook-Pro-2.local Testing
    /Users/Justin/logstash-1.5.2/testFile: file grew, old size 0, new size 20 {:level=>:debug, :file=>"filewatch/watch.rb", :line=>"96", :method=>"each"}
    _discover_file_glob: /Users/Justin/logstash-1.5.2/testFile: glob is: ["/Users/Justin/logstash-1.5.2/testFile"] {:level=>:debug, :file=>"filewatch/watch.rb", :line=>"132", :method=>"_discover_file"}

После того, как я изменил файл (в данном случае testFile), это появляется, но больше ничего:

/Users/Justin/logstash-1.5.2/testFile: file grew, old size 20, new size 29 {:level=>:debug, :file=>"filewatch/watch.rb", :line=>"96", :method=>"each"}
_discover_file_glob: /Users/Justin/logstash-1.5.2/testFile: glob is: ["/Users/Justin/logstash-1.5.2/testFile"] {:level=>:debug, :file=>"filewatch/watch.rb", :line=>"132", :method=>"_discover_file"}

Кроме того, он, кажется, не падает или что-то в этом роде. Он видит, что файл изменился, но не запускает свою функцию для вывода.


person Justin Cuaresma    schedule 21.07.2015    source источник
comment
Что вы имеете в виду под изменением файла . Вы редактируете файл, заменяете все содержимое или добавляете к нему?   -  person Alain Collins    schedule 22.07.2015
comment
Эй, Ален! Я просто присоединяюсь к нему.   -  person Justin Cuaresma    schedule 22.07.2015
comment
Вы нашли решение своей проблемы?, если да, пожалуйста, напишите.   -  person Ashish Sharma    schedule 22.06.2016


Ответы (1)


в конфигурационном файле logstash есть опция.

 input {
 file {
 discover_interval => ... # number (optional), default: 15
 stat_interval => ... # number (optional), default: 1
 sincedb_path => ... # string (optional)
 sincedb_write_interval => ... # number (optional), default: 15
 }
}

здесь discover_interval * stat_interval = seconds подождите 15 секунд. если все еще сталкиваетесь с той же проблемой, удалите файлы .sincedb_*. и перезапустите службу logstash. Поскольку БД хранит информацию обо всех обработанных файлах. Я надеюсь, что это сработает.

person pl_rock    schedule 22.07.2015
comment
Все еще не работает :( Просто продолжает выводить: _discover_file_glob: /Users/Justin/logstash-1.5.2/testFile: glob is: [/Users/Justin/logstash-1.5.2/testFile] {:level=›:debug , :file=›filewatch/watch.rb, :line=›132, :method=›_discover_file} - person Justin Cuaresma; 22.07.2015
comment
пожалуйста, удалите logstash и переустановите новый logstash или попробуйте другую версию logstash. в logstash 1.5.0 была ошибка. Я не знаю, эта ошибка исправлена ​​или нет. см. также здесь discuss.elastic.co /т/ - person pl_rock; 22.07.2015