我试图从elasticsearch中的/var/log/wtmp读取访问日志
使用last -F /var/log/wtmp登录到该框时,我可以读取该文件
我让logstash运行并将日志发送到elasticsearch,这里是logstash文件。
input {
file {
path => "/var/log/wtmp"
start_position => "beginning"
}
}
output {
elasticsearch {
host => localhost
protocol => "http"
port => "9200"
}
}在elasticsearch中显示的是

G
发布于 2015-11-05 13:20:41
一旦我用更少的方式打开文件,我只能看到二进制数据。现在logstash无法理解这些数据。像下面这样的日志存储文件应该工作得很好-
input {
pipe {
command => "/usr/bin/last -f /var/log/wtmp"
}
}
output {
elasticsearch {
host => localhost
protocol => "http"
port => "9200"
}
}发布于 2015-11-05 14:12:14
Vineeth的回答是正确的,但以下更干净的配置也有效:
input { pipe { command => "last" } }last /var/log/wtmp和last完全一样。
抽筋,抽筋,砰是用来跟踪用户登录和注销的Unix文件。它们不能直接读取,因为它们不是常规文本文件。但是,有一个last命令以纯文本显示/var/log/wtmp的信息。
$ last --help
Usage:
last [options] [<username>...] [<tty>...]我可以使用最后一次-F /var/log/wtmp登录到框中读取文件
我怀疑这一点。-F标志所做的事情:
-F, --fulltimes print full login and logout times and dates因此,last -F /var/log/wtmp将/var/log/wtmp解释为用户名,不会打印任何登录信息。
-f标志所做的事情:
-f, --file <file> use a specific file instead of /var/log/wtmphttps://stackoverflow.com/questions/33544655
复制相似问题