# Parse 4 digit millisecond timestamp in correct format and then replace @timestamp with log\_timestamp

**URL:** <https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906>\
**Category:** Logstash\
**Created:** [August 31, 2018, 7:01pm UTC](https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906 "2018-08-31T19:01:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![simmi\_a](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@simmi\_a](https://discuss.elastic.co/u/simmi_a)\
**Post date:** [August 31, 2018, 7:01pm UTC](https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906/1 "2018-08-31T19:01:22Z")

</div>

I have log time in 4 digit milliseconds  
2018-08-30 22:44:34. **1524** 13273641624629889532273 Error Error saving Api Log data

Tried this to parse it in correct time format but it doesn't work. I have to replace the @timestamp time with log\_timestamp

grok  
{  
match =\> { "message" =\> "%{TIMESTAMP\_ISO8601:log\_timestamp} %{WORD:token} %{LOGLEVEL:loglevel}" }  
}  
date {  
match =\> ["log\_timestamp","UNIX\_MS"]  
target =\> "logTime"  
remove\_field =\> ["log\_timestamp"]  
match =\> ["logTime", "YYYY-MM-dd HH:mm:ss,SSS", "YYYY-MM-dd HH:mm:ss", "ISO8601"]  
add\_field =\> { "Status" =\> "Matched"}  
remove\_field =\> ["logTime"]  
}  
}  
}  
I would appreciate the help on converting this epoch time format to the one which ELK supports.

---

<div class="post-metadata">

**Author:** ![Harshad\_Velapure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshad_velapure/32/33684_2.png) [@Harshad\_Velapure](https://discuss.elastic.co/u/Harshad_Velapure)\
**Post date:** [August 31, 2018, 10:15pm UTC](https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906/2 "2018-08-31T22:15:40Z")

</div>

Hello,

Check this link

[https://discuss.elastic.co/t/what-is-the-date-format-to-be-used-with-logstash-to-match-9-digits-millisecond/107032/2](https://discuss.elastic.co/t/what-is-the-date-format-to-be-used-with-logstash-to-match-9-digits-millisecond/107032/2)

---

<div class="post-metadata">

**Author:** ![simmi\_a](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@simmi\_a](https://discuss.elastic.co/u/simmi_a)\
**Post date:** [September 4, 2018, 1:10pm UTC](https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906/3 "2018-09-04T13:10:56Z")

</div>

i saw that, it says "You may need to parse out the last 6 decimals and put these into a separate field."

how to do this?

---

<div class="post-metadata">

**Author:** ![simmi\_a](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@simmi\_a](https://discuss.elastic.co/u/simmi_a)\
**Post date:** [September 4, 2018, 5:32pm UTC](https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906/4 "2018-09-04T17:32:30Z")

</div>

@magnusbaeck Can you help please?

---

<div class="post-metadata">

**Author:** ![simmi\_a](https://avatars.discourse-cdn.com/v4/letter/s/ecc23a/32.png) [@simmi\_a](https://discuss.elastic.co/u/simmi_a)\
**Post date:** [September 6, 2018, 4:36pm UTC](https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906/5 "2018-09-06T16:36:28Z")

</div>

Can anybody help with this issue? I need to parse 4 digit millisecond timestamp in ELK supported format?

---

<div class="post-metadata">

**Author:** ![Harshad\_Velapure](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/harshad_velapure/32/33684_2.png) [@Harshad\_Velapure](https://discuss.elastic.co/u/Harshad_Velapure)\
**Post date:** [September 12, 2018, 8:04pm UTC](https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906/6 "2018-09-12T20:04:35Z")

</div>

I haven't tried this yet but you can use gsub to get last 4 decimals and store in other field  
then you can merge that field with time field

Problem is,, this newly created field will be string

---

<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 10, 2018, 8:08pm UTC](https://discuss.elastic.co/t/parse-4-digit-millisecond-timestamp-in-correct-format-and-then-replace-timestamp-with-log-timestamp/146906/7 "2018-10-10T20:08:13Z")

</div>

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