# Where's the % coming from?

**URL:** <https://discuss.elastic.co/t/wheres-the-coming-from/238277>\
**Category:** Logstash\
**Created:** [June 23, 2020, 2:18pm UTC](https://discuss.elastic.co/t/wheres-the-coming-from/238277 "2020-06-23T14:18:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mykael](https://avatars.discourse-cdn.com/v4/letter/m/ec9cab/32.png) [@mykael](https://discuss.elastic.co/u/mykael)\
**Post date:** [June 23, 2020, 2:18pm UTC](https://discuss.elastic.co/t/wheres-the-coming-from/238277/1 "2020-06-23T14:18:39Z")

</div>

I'm using the following to add an ingestion timestamp to my records:

```
  ruby {
     code => 'event.set("ingest_time", Time.now.strftime("%Y-%m-%d %H:%M:%S.%3"))'
  }

```

What I'm getting in my data, thought, is:

`ingest_time 2020%-06-23 22:09:45.`

Which is missing the milliseconds - does logstash not support the %3 token?

It also has an extra % after the year - which must be coming out of ruby as the % in the format string is after the hyphen ( %Y-%m... ).

Any ideas?

---

<div class="post-metadata">

**Author:** ![Rahul\_Kumar4](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahul_kumar4/32/67369_2.png) [@Rahul\_Kumar4](https://discuss.elastic.co/u/Rahul_Kumar4)\
**Post date:** [June 23, 2020, 4:26pm UTC](https://discuss.elastic.co/t/wheres-the-coming-from/238277/2 "2020-06-23T16:26:22Z")

</div>

> [@mykael](#):
>
> Which is missing the milliseconds - does logstash not support the %3 token?

Try `.%L` instead of `.%3` for the miliseconds part. Not sure where the `%` after the year comes from. Not getting that in Ruby interpreter.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 23, 2020, 4:46pm UTC](https://discuss.elastic.co/t/wheres-the-coming-from/238277/3 "2020-06-23T16:46:20Z")

</div>

> [@mykael](#):
>
> ```auto
> ruby {
> code => 'event.set("ingest_time", Time.now.strftime("%Y-%m-%d %H:%M:%S.%3"))'
> }
> 
> ```

%L or %3N will produce 3 digits of sub-second precision. I do not get the % after the year in 7.8.0

```
"ingest_time" => "2020-06-23 12:45:02.274",

```

---

<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 21, 2020, 4:46pm UTC](https://discuss.elastic.co/t/wheres-the-coming-from/238277/4 "2020-07-21T16:46:24Z")

</div>

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