具有 X-Ray 跟踪 ID,但使用 X-Ray 控制台搜索显示 "Data not found"

Have X-Ray trace ID, but searching using X-Ray console says "Data not found"

在我的 API 网关日志条目中指示超时,我正在调查它的来源。日志条目有一个 X-Ray 跟踪 ID,但是当我使用 X-Ray 搜索它时,我得到“找不到数据”。

我预计至少有一个节点 APIG 会出现在 X-Ray 中。我错过了什么?

API Gateway CloudWatch Logs Insights 我找不到

的跟踪

查询字符串:

fields @timestamp, @message
| filter @message like "92300847-04fd-4969-8728-92d12887ee44"
| sort @timestamp desc
| limit 20
@timestamp @message
2021-02-12 23:19:52.559 (92300847-04fd-4969-8728-92d12887ee44) X-ray Tracing ID : Root=1-60270cfb-2e033ce35d226f3f1fc240b0
2021-02-12 23:19:52.558 (92300847-04fd-4969-8728-92d12887ee44) Execution failed due to a timeout error
2021-02-12 23:19:52.558 (92300847-04fd-4969-8728-92d12887ee44) Gateway response type: DEFAULT_5XX with status code: 504
2021-02-12 23:19:52.558 (92300847-04fd-4969-8728-92d12887ee44) Method completed with status: 504
2021-02-12 23:19:23.558 (92300847-04fd-4969-8728-92d12887ee44) API Key authorized because method 'GET /shifts' does not require API Key. Request will not contribute to throttle or quota limits
2021-02-12 23:19:23.558 (92300847-04fd-4969-8728-92d12887ee44) Usage Plan check succeeded for API Key and API Stage eejmp2ziyc/prod
2021-02-12 23:19:23.558 (92300847-04fd-4969-8728-92d12887ee44) Starting execution for request: 92300847-04fd-4969-8728-92d12887ee44
2021-02-12 23:19:23.558 (92300847-04fd-4969-8728-92d12887ee44) HTTP Method: GET, Resource Path: /shifts
2021-02-12 23:19:23.557 (92300847-04fd-4969-8728-92d12887ee44) Verifying Usage Plan for request: 92300847-04fd-4969-8728-92d12887ee44. API Key: API Stage: eejmp2ziyc/prod
2021-02-12 23:19:23.556 (92300847-04fd-4969-8728-92d12887ee44) Extended Request Id: ap73UGVmPHcFX1g=

Api Gateway CloudWatch Logs Insights 我可以找到

的跟踪

查询字符串:

fields @timestamp, @message
| sort @timestamp desc
| filter @message like "b80e4922-7f18-4024-8f9a-fadba068f0c1"

@timestamp @message
2021-02-17 07:15:23.939 (b80e4922-7f18-4024-8f9a-fadba068f0c1) Successfully completed execution
2021-02-17 07:15:23.939 (b80e4922-7f18-4024-8f9a-fadba068f0c1) Method completed with status: 200
2021-02-17 07:15:23.939 (b80e4922-7f18-4024-8f9a-fadba068f0c1) AWS Integration Endpoint RequestId : 9686fa9d-262d-41e9-bd3f-b261ad06297a
2021-02-17 07:15:23.939 (b80e4922-7f18-4024-8f9a-fadba068f0c1) X-ray Tracing ID : Root=1-602cc28a-5b6bd5b11e2a02235a292a15
2021-02-17 07:15:22.457 (b80e4922-7f18-4024-8f9a-fadba068f0c1) Starting execution for request: b80e4922-7f18-4024-8f9a-fadba068f0c1
2021-02-17 07:15:22.457 (b80e4922-7f18-4024-8f9a-fadba068f0c1) HTTP Method: GET, Resource Path: /scheduleSummary
2021-02-17 07:15:22.456 (b80e4922-7f18-4024-8f9a-fadba068f0c1) API Key authorized because method 'GET /scheduleSummary' does not require API Key. Request will not contribute to throttle or quota limits
2021-02-17 07:15:22.456 (b80e4922-7f18-4024-8f9a-fadba068f0c1) Usage Plan check succeeded for API Key and API Stage eejmp2ziyc/prod
2021-02-17 07:15:22.454 (b80e4922-7f18-4024-8f9a-fadba068f0c1) Verifying Usage Plan for request: b80e4922-7f18-4024-8f9a-fadba068f0c1. API Key: API Stage: eejmp2ziyc/prod
2021-02-17 07:15:22.453 (b80e4922-7f18-4024-8f9a-fadba068f0c1) Extended Request Id: a4NVpGGIPHcFevg=

X 射线

拥有跟踪 ID 并不意味着被采样。

Trace Id 只是Trace Header 的一部分。例如看这个:

X-Amzn-Trace-Id: Root=1-5759e988-bd862e3fe1be46a994272793;Sampled=0

如您所见,我们有 traceID,但样本已关闭(样本=0)

要了解您的轨迹是否被采样,您需要查看 X-Amzn-Trace-Id

您可以在此处找到更多信息: https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader

默认抽样是5%,如果你想对所有或更多的请求使用它,你可以改变抽样: https://docs.aws.amazon.com/xray/latest/devguide/xray-console-sampling.html

我向 AWS 提出了一个支持案例来询问这个问题。他们的回复是:

It looks like X-Ray had some segment loss around that time-frame which could have been the reason for the missing traces. Trace loss should be expected sometimes. X-Ray doesn't charge the customer for any traces which were not stored.