使用 CloudWatch Logs Insights 浏览网络监测仪测量数据 - Amazon CloudWatch

使用 CloudWatch Logs Insights 浏览网络监测仪测量数据

您可以使用 CloudWatch Logs Insights 查询来筛选特定城市或地理位置(客户端位置)、客户端 ASN(ISP)和 AWS 源位置的日志子集。Amazon CloudWatch 网络监测仪将可用性和往返时间的精细测量数据发布到 CloudWatch Logs,您可以使用 CloudWatch Logs Insights 进行浏览。

要详细了解网络监测仪中的客户端位置准确性,请参阅 网络监测仪中的地理位置信息和准确性

本节中的示例可以帮助您创建 CloudWatch Logs Insights 查询,以了解有关您自己的应用程序流量测量数据和指标的更多信息。如果您在 CloudWatch Logs Insights 中使用这些示例,请将 monitorName 替换为您自己的监测仪名称。

查看流量优化建议

在 Internet Monitor 的流量洞察选项卡上,您可以按位置筛选并查看流量优化建议。要查看此选项卡上的流量优化建议部分中显示的相同信息,但不使用位置粒度筛选条件,您可以使用以下 CloudWatch Logs Insights 查询。

  1. 在 AWS Management Console 中,导航到 CloudWatch Logs Insights。

  2. 对于 Log Group(日志组),选择 /aws/internet-monitor/monitorName/byCity/aws/internet-monitor/monitorName/byCountry,然后指定时间范围。

  3. 添加以下查询,然后运行该查询。

fields @timestamp, clientLocation.city as @city, clientLocation.subdivision as @subdivision, clientLocation.country as @country, `trafficInsights.timeToFirstByte.currentExperience.serviceName` as @serviceNameField, concat(@serviceNameField, ` (`, `serviceLocation`, `)`) as @currentExperienceField, concat(`trafficInsights.timeToFirstByte.ec2.serviceName`, ` (`, `trafficInsights.timeToFirstByte.ec2.serviceLocation`, `)`) as @ec2Field, `trafficInsights.timeToFirstByte.cloudfront.serviceName` as @cloudfrontField, concat(`clientLocation.networkName`, ` (AS`, `clientLocation.asn`, `)`) as @networkName | filter ispresent(`trafficInsights.timeToFirstByte.currentExperience.value`) | stats avg(`trafficInsights.timeToFirstByte.currentExperience.value`) as @averageTTFB, avg(`trafficInsights.timeToFirstByte.ec2.value`) as @ec2TTFB, avg(`trafficInsights.timeToFirstByte.cloudfront.value`) as @cloudfrontTTFB, sum(`bytesIn` + `bytesOut`) as @totalBytes, latest(@ec2Field) as @ec2, latest(@currentExperienceField) as @currentExperience, latest(@cloudfrontField) as @cloudfront, count(*) by @networkName, @city, @subdivision, @country | display @city, @subdivision, @country, @networkName, @totalBytes, @currentExperience, @averageTTFB, @ec2, @ec2TTFB, @cloudfront, @cloudfrontTTFB | sort @totalBytes desc

查看互联网可用性和 RTT(p50、p90 和 p95)

要查看流量的互联网可用性和往返时间(p50、p90 和 p95),您可以使用以下 CloudWatch Logs Insights 查询。

最终用户地理位置:美国伊利诺伊州芝加哥

最终用户网络(ASN):AS7018

AWS 服务位置:美国东部(弗吉尼亚州北部)地区

要查看日志,请执行以下操作:

  1. 在 AWS Management Console 中,导航到 CloudWatch Logs Insights。

  2. 对于 Log Group(日志组),选择 /aws/internet-monitor/monitorName/byCity/aws/internet-monitor/monitorName/byCountry,然后指定时间范围。

  3. 添加以下查询,然后运行该查询。

该查询将返回在选定时间范围内从伊利诺伊州芝加哥的 AS7018 连接到美国东部(弗吉尼亚州北部)地区用户的所有性能数据。

fields @timestamp, internetHealth.availability.experienceScore as availabilityExperienceScore, internetHealth.availability.percentageOfTotalTrafficImpacted as percentageOfTotalTrafficImpacted, internetHealth.performance.experienceScore as performanceExperienceScore, internetHealth.performance.roundTripTime.p50 as roundTripTimep50, internetHealth.performance.roundTripTime.p90 as roundTripTimep90, internetHealth.performance.roundTripTime.p95 as roundTripTimep95 | filter clientLocation.country == `United States` and clientLocation.city == `Chicago` and serviceLocation == `us-east-1` and clientLocation.asn == 7018

有关更多信息,请参阅使用 CloudWatch Logs Insights 分析日志数据