0

ファイルから読み取り、各イベントをコンソール (またはファイル) に出力しようとしています。ファイルに追加して、これを 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"}

また、クラッシュなどはしていないようです。ファイルが変更されたことがわかりますが、その機能を実行して出力しません。

4

1 に答える 1

0

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サービスを再起動します。sincedb ストアは、処理されたすべてのファイルの詳細を示します。うまくいくことを願っています。

于 2015-07-22T03:45:39.740 に答える