API Gateway $context.requestTimeEpoch timestamp is in seconds

0

The API Gateway documentation claims $context.requestTimeEpoch is in millseconds (source). However, when logging this field to cloudwatch and pushing this property to EventBridge, the timestamp appears to be in seconds.

API gateway logging configuration contains "requestTimeEpoch": "$context.requestTimeEpoch" Example logging event:

{ ...
    "requestTime": "07/Feb/2024:18:44:06 +0000",
    "requestTimeEpoch": "1707331446", # clearly in seconds
    "httpMethod": "POST",

I'm also using the $context.requestTimeEpoch property for an EventBridge integration for the Time property. When looking at the events in cloudwatch, they are also in seconds:

{ ...
    "account": "...",
    "time": "2024-02-07T18:44:06Z", #no ms precision
    "region": "us-east-2",

I tried to provide feedback to the support documentation and the response I got was:

The output of $context.requestTimeEpoch is in ms. It sounds like you actually have a technical support question.

It's hard to believe I'm doing something wrong here, unless both Cloudwatch and Eventbridge are cutting the precision of this property.

Is there any way to get millisecond precision from this property?

1 Answer
0

For others who have a similar issue, this turns out be a mismatch between the REST and HTTP API behaviors for that property. For HTTP APIs, the documentation just says "The Epoch-formatted request time". Even though it doesn't specify precision, I guess you could assume it would be in seconds. I personally believe the documentation should state that, though.

I guess there is no way to get millisecond precision using HTTP APIs.

Drew
answered 2 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions