# Handlng microsecond timestamps

**URL:** <https://discuss.elastic.co/t/handlng-microsecond-timestamps/38350>\
**Category:** Logstash\
**Created:** [January 4, 2016, 10:20pm UTC](https://discuss.elastic.co/t/handlng-microsecond-timestamps/38350 "2016-01-04T22:20:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbach](https://avatars.discourse-cdn.com/v4/letter/b/d26b3c/32.png) [@bbach](https://discuss.elastic.co/u/bbach)\
**Post date:** [January 4, 2016, 10:20pm UTC](https://discuss.elastic.co/t/handlng-microsecond-timestamps/38350/1 "2016-01-04T22:20:06Z")

</div>

Elasticseach search's native timestamp can currently only handle times with millisecond resolution and I know there are people out there looking to store timestamps with as least microsecond (usec) resolution.

My workaround for this was to parse the timestamp from my log files into a 'usec since epoch' field using ruby:

```
    # Assumes a field 'log_datetime' formatted as 'yyyy-MM-dd HH:mm:ss.uuuuuu'
    ruby {
        code => "
            t = Time.parse(event['log_datetime'], '%Y-%m-%d %H:%M:%S.%L')
            event['timestamp_us'] = t.to_i * 1000000 + t.usec
       "
    }

```

I can then use this field for sorting where there are mutliple events within a millisecond. If anyone has a better solution for handling this, I'd love to hear it.

Note: In Kibana, by default, the timestamp\_us field will display as something like 1,451,944,998,000,000. If you want to get rid of the commas, under the settings-\>indicies tab, you can edit the display format -- just enter a 0 (zero) as the format.

-- Bud

---

<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:** [July 6, 2017, 5:16am UTC](https://discuss.elastic.co/t/handlng-microsecond-timestamps/38350/2 "2017-07-06T05:16:53Z")

</div>


