# Event.duration bug

**URL:** <https://discuss.elastic.co/t/event-duration-bug/286733>\
**Category:** Logstash\
**Created:** [October 14, 2021, 2:12pm UTC](https://discuss.elastic.co/t/event-duration-bug/286733 "2021-10-14T14:12:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![maltewhiite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maltewhiite/32/94551_2.png) [@maltewhiite](https://discuss.elastic.co/u/maltewhiite)\
**Post date:** [October 14, 2021, 2:12pm UTC](https://discuss.elastic.co/t/event-duration-bug/286733/1 "2021-10-14T14:12:31Z")

</div>

I have a field as a double in milliseconds. I want to turn it into nanoseconds and apply it to the event.duration field in logstash, so I can monitor how long certain events take for my machines to process.

Here is the Logstash code:

```auto
        if [idm][response] == "RESULT" {
            mutate {
                convert => {
                    "[idm][result][etime]" => "float"
                    "[idm][result][optime]" => "float"
                    "[idm][result][wtime]" => "float"
                    "[idm][result][tag]" => "integer"
                }
            }
            if [idm][result][etime] {
                ruby {
                    code => "event.set('[event][duration]', ((event.get('[idm][result][etime]').to_f) * 1000000).round)"
                }
            }
        }

```

Here is how it looks in Kibana. It only shows 0.0 or 0.1:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/a/aa3f1cbc29a938144333621a34c3a6508ece0f3f.png)

Now, the strange part is that it looks like it works, if I do the following, and filter for value:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/a/aa5790fe0e574bdab64347c5531f4767ac704ffd.png)

And then edit the filter, it will actually show me the correct value that I want the event.duration field to have:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/8/78595184579c2f27cd91c0d2eb9a8d1a4af0856f.png)

So why is it showing 0.0 and not 1165? The Filter knows it is 1165 but the Kibana UI shows 0.0  
See, the UI shows 0.0 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/f/9f152bd51afb647e61d2dd1957744e9086db4f5b.png)

But the JSON shows the right number: ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/e/be9d9df70f8196b820d44fba5700a011819ba68f.png)

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [October 15, 2021, 3:36pm UTC](https://discuss.elastic.co/t/event-duration-bug/286733/2 "2021-10-15T15:36:40Z")

</div>

In Kibana, check your index pattern for that field and define the number of decimal places you want to show for event.duration

---

<div class="post-metadata">

**Author:** ![maltewhiite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maltewhiite/32/94551_2.png) [@maltewhiite](https://discuss.elastic.co/u/maltewhiite)\
**Post date:** [October 18, 2021, 7:22am UTC](https://discuss.elastic.co/t/event-duration-bug/286733/3 "2021-10-18T07:22:57Z")

</div>

But the real number for event.duration in the example in the JSON is 1165

Showing more decimal places wouldn't change anything?

---

<div class="post-metadata">

**Author:** ![maltewhiite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maltewhiite/32/94551_2.png) [@maltewhiite](https://discuss.elastic.co/u/maltewhiite)\
**Post date:** [October 18, 2021, 7:29am UTC](https://discuss.elastic.co/t/event-duration-bug/286733/4 "2021-10-18T07:29:42Z")

</div>

I checked anyway, just to be sure, and it turns out you pointed me in the right direction.

The Documentation tells us to set event.duration as the Duration in Nanoseconds. So I just assumed that the Kibana field would show it in Nanoseconds as well. But apparently it is showing it in Milliseconds. Doesn't seem very intuitive, but oh well.

I can now raise the Decimal places as I see fit. Thanks.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/9/99e4957eb7e50a3f2117eef62cb92b03456cc580.png)

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [October 18, 2021, 1:45pm UTC](https://discuss.elastic.co/t/event-duration-bug/286733/5 "2021-10-18T13:45:53Z")

</div>

Wonderful! Glad you got it sorted out 🙂

---

<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:** [November 15, 2021, 1:46pm UTC](https://discuss.elastic.co/t/event-duration-bug/286733/6 "2021-11-15T13:46:38Z")

</div>

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