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 個回答
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
已回答 3 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南