Skip to content

Subtracting timestamps in VRL #22358

Answered by Maixy
Maixy asked this question in Q&A
Feb 3, 2025 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Solved!

I had a couple different issues going on.
The first one was that I was running vector v0.42.0 locally, which didn't have support for the timezone parameter in parse_timestamp(). It seemed like the VRL library would automatically just detect the timezone of the host when doing calculations, but was inconsistent about that when using a VRL generated timestamp like now().

After upgrading to v.0.44 I've been able to pass in the correct TZ data as a third parameter:

parsed_ts = parse_timestamp!(.ts,      "%Y-%m-%dT%H:%M:%S.%fZ", "UTC")
parsed_now = parse_timestamp!(now(),    "%Y-%m-%dT%H:%M:%S.%fZ", "UTC")
.delta_in_seconds = to_float(parsed_now) - to_float(parsed_ts)

https://playgrou…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Maixy
Comment options

Answer selected by Maixy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
vrl: compiler Changes made to the VRL compiler.
1 participant