不为失败找理由,要为成功找方法。

[ERROR][logstash.filters.ruby ] Ruby exception occurred: undefined method `time' for nil:NilClass

Logstash | 作者 Dm | 发布于2017年08月20日 | 阅读数:11728

5.2.1版本
在filter中处理时间:
ruby {
code => "event.set('utctime', event.get('utctime').time + 8*60*60)"
}
后台报错:
[ERROR][logstash.filters.ruby ] Ruby exception occurred: undefined method `time' for nil:NilClass
已邀请:

rochy - rochy_he

赞同来自:

请参考下面的案例(看起来你的案例里面的错误是 utctime 字段获取到的值为空):
input { stdin {} }
output { stdout { codec => rubydebug } }
filter {
date {
match => ["message","UNIX_MS"]
target => "@timestamp"
}
ruby {
code => "event.set('timestamp', event.get('@timestamp').time.localtime + 8*60*60)"
}
ruby {
code => "event.set('@timestamp',event.get('timestamp'))"
}
mutate {
remove_field => ["timestamp"]
}
}

Naylor

赞同来自:

 date {
match => ["message","UNIX_MS"]
target => "@timestamp"
}
message   是什么意思?
target中对应的  @timestamp  又是什么意思?
 

要回复问题请先登录注册