在logstash 2.4
上使用Ubuntu 16.04
(我有理由)
root@logbox:/etc/logstash/conf.d# ls -al
total 16
drwxrwxr-x 2 root root 4096 Nov 2 19:53 .
drwxrwxr-x 3 root root 4096 Nov 2 15:46 ..
-rwxrwxrwx 1 root root 277 Nov 2 19:52 01_01_input.conf
-rwxrwxrwx 1 root root 604 Nov 2 19:48 03_02_output_pa_http.conf
root@logbox:/etc/logstash/conf.d# cat *.conf
input {
stdin {}
file {
path => "/usr/share/logstash/files/production_input.txt"
start_position => "beginning"
# codec => plain { charset => "ISO-8859-1" }
codec => json
# add_field => [ 'redis_db', '10' ]
}
}
output {
stdout {}
}
root@logbox:/etc/logstash/conf.d# ls -al /usr/share/logstash/files/production_input.txt
-rwxrwxrwx 1 root root 11910 Nov 2 16:09 /usr/share/logstash/files/production_input.txt
但是...
vagrant@logbox:/etc/logstash/conf.d$ sudo tail -f /var/log/logstash/logstash*
Sending logstash logs to /var/log/logstash/logstash.log.
==> /var/log/logstash/logstash.log <==
{:timestamp=>"2018-11-02T19:59:52.947000+0000", :message=>"Pipeline main started"}
==> /var/log/logstash/logstash.stdout <==
{:timestamp=>"2018-11-02T19:59:52.947000+0000", :message=>"Pipeline main started"}
文件未打印在stdout
中...我已经尝试了两种编解码器(json
和plain
)
编辑:实际上可能是文件一次只读的情况;这和sincedb
有关系吗?
如何强制Logstash重新读取? start_position => beginning
还不够吗?
答案 0 :(得分:1)
start_position
在第一次读取文件时使用。
如果要强制logstash再次读取它,则需要在文件输入插件conf中添加以下参数:
sincedb_path => "/dev/null"
请阅读以获取更多说明 How to force Logstash to reparse a file?