我在我的logstash过滤器中收到以下格式的@timestamp
"@timestamp" => "2016-11-28T19:19:05.627Z"
我想通过添加新的周和月字段来提取文本格式的工作日和月份值。我的输出应该是这样的
week-day:monday
month:nov
我正在使用一些 ruby 代码
ruby {
code => '
require "time"
event["week-day"] = event["@timestamp"].strftime "%a"
'
}
但出现错误
Ruby exception occurred: undefined method `strftime' for "2016-11-28T19:19:05.804Z":LogStash::Timestamp {:level=>:error}
有没有办法在 grok 或相同的 ruby 代码中做同样的事情?
任何帮助将不胜感激!!
最佳答案
你已经快到了,你只是错过了一些东西:
ruby {
code => '
require "time"
event["week-day"] = event["@timestamp"].time.strftime "%a"
'
}
关于logstash - 从logstash中的时间戳中提取文本格式的工作日,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40851942/