2017-11-17 80 views
1

Logstashを指定したログファイルから読み込むように設定しようとしています。 stdinから読み込むように設定すると、期待どおりに動作し、Logstashからのメッセージが入力され、Kibana UIに表示されます。私はファイル入力でLogstashを実行するとLogstashが設定された入力ファイルから読み込まない

$ cat /tmp/logstash-stdin.conf 
input { 
    stdin {} 
} 
output { 
    elasticsearch { hosts => ["localhost:9200"] } 
    stdout { codec => rubydebug } 

} 

$./logstash -f /tmp/logstash-stdin.conf 
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults 
Could not find log4j2 configuration at path //usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console 
The stdin plugin is now waiting for input: 
hellloooo 
{ 
     "@version" => "1", 
      "host" => "myhost.com", 
    "@timestamp" => 2017-11-17T16:05:41.595Z, 
     "message" => "hellloooo" 
} 

はしかし、私は、ファイルがLogstashにロードされるという兆候を取得していない、そしてそれはKibanaには表示されません。

$ cat /tmp/logstash-simple.conf 
input { 
    file { 
    path => "/tmp/test_log.txt" 
    type => "syslog" 
    } 
} 
output { 
    elasticsearch { hosts => ["localhost:9200"] } 
    stdout { codec => rubydebug } 
} 


$ ./logstash -f /tmp/logstash-simple.conf 
WARNING: Could not find logstash.yml which is typically located in $LS_HOME/config or /etc/logstash. You can specify the path using --path.settings. Continuing using the defaults 
Could not find log4j2 configuration at path //usr/share/logstash/config/log4j2.properties. Using default config which logs errors to the console 

Logstashが設定ファイルを取り込まない理由をトラブルシューティングする方法の提案はありますか?

+0

しかし、Logstashを起動した後でファイルに書き込んでいますか? – mustaccio

+0

私はそうではないと分かっていませんでしたが、これは必要なのですが...既存のログファイルを読み取るオプションはありませんか? – ab11

+0

@mustaccioどのようにフォルダから読み込むためにlogstashを設定するのですか?次のように設定を変更すると、logstashの起動時にフォルダにファイルがあるかどうかに関係なく、何も取り込まれません。また、logstashが実行されているときにファイルを修正するか、logstashの実行中に新しいファイルをフォルダに移動します。ファイル{ パス=> "/tmp/logstash_input/*.*" start_position =>開始 } – ab11

答えて

1

デフォルトでは、ファイル入力プラグインはファイルの最後に読み込みを開始するので、Logstashの開始後に追加された行だけが処理されます。起動時に既存のすべての回線を読み取るには、"start_position" => "beginning"というオプションを構成に追加します(explained in documentation)。

+0

ありがとう、これは働いた。どのように私はフォルダから読み取るためにlogstashを設定する任意の提案?次のように設定を変更すると、logstashの起動時にフォルダにファイルがあるかどうかに関係なく、何も取り込まれません。また、logstashが実行されているときにファイルを修正するか、logstashの実行中に新しいファイルをフォルダに移動します。 file {path => "/tmp/logstash_input/*.*" start_position => "beginning"} – ab11

+0

Logstashはファイルの読み込みを忘れてしまいました。したがって、ファイルが既に読み込まれている場合、それは再び読み取られません。 https://www.elastic.co/guide/en/logstash/current/plugins-inputs-file.htmlを参照してください。 'sincedb_path =>/dev/null'を設定して、logstashが読み込まれたものを保存しないようにすることができます。 – baudsp

関連する問題