Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing a timestamp to use with CW Log Insights functions

Attempting to use a built-in Cloudwatch Log function like "date_floor" with a 8601 timestamp string like "2020-03-24T19:03:34.645Z" gives back an "Invalid date" error in Cloudwatch Log Insights.

Does anyone know what is required to parse/cast timestamps that appear within your logs so they can be used with the built-in date/time functions?

My end goal is to compare a timestamp that appears within my logs with the built-in @ingestionTime field.

like image 833
scolestock Avatar asked Nov 17 '25 12:11

scolestock


1 Answers

Just came cross on this. Not sure if you already found your answer. You got "Invalid date" because "date_floor" function requires type of Timestamp, not String type. Nonetheless, I don't see any Datetime functions that can construct Timestamp from a String in AWS Cloudwatch User Guide even today. One option is to use epoch time (number) and convert it to Timestamp by using fromMillis(epoch).

like image 105
Etian Avatar answered Nov 21 '25 10:11

Etian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!