Logstash ruby convert seconds to milliseconds

(Kiran Tella) #1

I'm trying to convert responsetime from nginx access logs which is in seconds to milliseconds using ruby.

I was able to successfully GROK the access log.

grok {
match => { "message" => "%{IPV4:clientip} - - [%{HTTPDATE:requesttimestamp}] "%{WORD:httpmethod} /" %{NUMBER:responsecode:int} %{NUMBER:responsesize:int} "-" "-" "-" "%{NUMBER:responsetimems:float}""}
ruby {
code => "event.set('responsetimems', event.get('responsetimems').to_i * 1000))"

Am i doing anything wrong here ?

(Magnus B├Ąck) #2

That looks correct. What does an example event coming out of Logstash look like?

(Kiran Tella) #3

I fixed it. Its an extra ) at the end. Thanks.

(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.