# Logstash ruby convert seconds to milliseconds

**URL:** <https://discuss.elastic.co/t/logstash-ruby-convert-seconds-to-milliseconds/101508>\
**Category:** Logstash\
**Created:** [September 22, 2017, 2:37pm UTC](https://discuss.elastic.co/t/logstash-ruby-convert-seconds-to-milliseconds/101508 "2017-09-22T14:37:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ktella](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@ktella](https://discuss.elastic.co/u/ktella)\
**Post date:** [September 22, 2017, 2:37pm UTC](https://discuss.elastic.co/t/logstash-ruby-convert-seconds-to-milliseconds/101508/1 "2017-09-22T14:37:58Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 25, 2017, 5:51am UTC](https://discuss.elastic.co/t/logstash-ruby-convert-seconds-to-milliseconds/101508/2 "2017-09-25T05:51:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ktella](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@ktella](https://discuss.elastic.co/u/ktella)\
**Post date:** [September 27, 2017, 7:05pm UTC](https://discuss.elastic.co/t/logstash-ruby-convert-seconds-to-milliseconds/101508/3 "2017-09-27T19:05:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 25, 2017, 7:05pm UTC](https://discuss.elastic.co/t/logstash-ruby-convert-seconds-to-milliseconds/101508/4 "2017-10-25T19:05:31Z")

</div>

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