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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则