Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to parse timestamp of type millisecond since unix epoch #117

Open
jerome-kleinen-kbc-be opened this issue May 6, 2021 · 6 comments
Labels
type: bug A code related bug vrl: stdlib Changes to the standard library

Comments

@jerome-kleinen-kbc-be
Copy link

Vector Version

vector 0.13.1 (v0.13.1 x86_64-unknown-linux-gnu 2021-04-29)

Vector Configuration File

$ parse_timestamp!("1620291751177", "%s%3f")
function call error for "parse_timestamp" at (0:42): Invalid timestamp "1620291751177": premature end of input

$ parse_timestamp!("1620291751.177", "%s%.3f")
t'2021-05-06T09:02:31.177Z'

Debug Output

N/A

Expected Behavior

The first parse_timestamp command should have been able to parse the timestamp.

Actual Behavior

It didn't parse the timestamp.

@jerome-kleinen-kbc-be jerome-kleinen-kbc-be added the type: bug A code related bug label May 6, 2021
@jszwedko
Copy link
Member

jszwedko commented May 6, 2021

I dug into this a little and couldn't find a format specifier that would work for unix milliseconds in the time parsing library we use, chrono. I opened: chronotope/chrono#560

@yalinglee
Copy link

Would the solution proposed in the chrono issue also work for parsing unix microseconds like 1638777946995336?

@jszwedko
Copy link
Member

jszwedko commented Dec 6, 2021

@yalinglee yes, it looks like it would work for millisecond, microsecond, and nanosecond timestamps.

https://github.com/chronotope/chrono/pull/561/files#diff-abd7a03adfeaa1c9ca4623371f789cf48c5d794d82457a4068ad5be00fe7c784R225-R227

@yalinglee
Copy link

@jszwedko That's great to hear! Any chance this might be addressed in the near future? We'd love to try out vector but this is currently a blocker.

@jszwedko
Copy link
Member

jszwedko commented Dec 6, 2021

Unfortunately we are blocked on chrono until they merge that. I did leave a comment though so hopefully it'll get some attention soon.

As a workaround, you can use arithmetic to convert the timestamp to a float timestamp which Vector will interpret as seconds (with fractional seconds):

timestamp = 1620291751177
to_timestamp(timestamp / 1000000)

Does that make sense?

@yalinglee
Copy link

@jszwedko Thank you so much for getting the ball rolling on this, and yes the workaround should work in the meantime!

@JeanMertz JeanMertz added the vrl: stdlib Changes to the standard library label Jun 7, 2022
@fuchsnj fuchsnj transferred this issue from vectordotdev/vector Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A code related bug vrl: stdlib Changes to the standard library
Projects
None yet
Development

No branches or pull requests

4 participants