事情是這樣的:
前陣子工作上開發的 API 上線後,在當天的數千次 request 中,發生 5 次不明原因的錯誤(從 CloudWatch Dashboard 看到 API Gateway 的 5XX Error 出現大於零的數字)。
後來為了重現錯誤,用 K6 做了 soak test。在 30 分鐘內也的確出現數次錯誤。
不過 API Gateway 在 response payload 之中只給出「Internal Server Error」的訊息,為了進一步了解錯誤的原因,要參考 $context Variables for access logging only 章節在 Access Log 之中加入額外的資訊。比如說:
$context.authorize.error
$context.authorizer.error
$context.authenticate.error
$context.integration.error
$context.waf.error