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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인