0
点赞
收藏
分享

微信扫一扫

Logstash 本地调试日志笔记

rubydebug 格式输出

input {
    file {
        path            => ["/data/log/test.log"]  # 读取本地日志目录
        start_position  => "beginning"  # 每次重新启动从日志的开头读
        sincedb_path    => "/dev/null"  # 该参数用来指定sincedb文件名,但是如果我们设置为/dev/null这个linux系统上特殊的空洞文件,那么logstash每次重启进程的时候,尝试读取sincedb内容,都只会读到空洞,也就可以理解为前不有过运行记录,自然就从初始位置开始读取了!
        codec           => "json"  # 如果日志格式是json的,可以启动此参数
    }
 }

output {
    stdout {
        codec => rubydebug  # 以rubydebug格式在控制台输出
        # codec => json  # 以json格式在控制台输出
    }
}

json 格式输出

input {
    file {
        path            => ["/data/log/test.log"]
        start_position  => "beginning"
        sincedb_path    => "/dev/null"
    }
 }

output {
    stdout {
        # codec => rubydebug
        codec => json
    }
}

测试配置文件的正确性

/usr/share/logstash/bin/logstash -f /usr/share/logstash/test.conf -t

举报

相关推荐

0 条评论