

# CloudWatch Logs Insights를 사용하여 Internet Monitor 측정값 살펴보기
<a name="CloudWatch-IM-view-cw-tools-logs-insights"></a>

CloudWatch Logs Insights 쿼리를 사용하여 특정 도시 또는 지리(클라이언트 위치), 클라이언트 ASN(ISP) 및 AWS 소스 위치에 대한 로그 하위 세트를 필터링할 수 있습니다. Internet Monitor는 CloudWatch Logs Insights를 사용하여 살펴볼 수 있는 CloudWatch Logs에 대한 가용성 및 왕복 시간의 세분화된 측정값을 게시합니다.

Internet Monitor의 클라이언트 위치 정확도에 대해 자세히 알아보려면 [Internet Monitor의 지리적 위치 정보 및 정확도](CloudWatch-IM-inside-internet-monitor.md#IMGeolocationSourceAccuracy)를 참조하세요.

이 섹션의 예를 통해 자체 애플리케이션 트래픽 측정 및 지표에 대해 자세히 알아볼 수 있는 CloudWatch 로그 인사이트 쿼리를 생성할 수 있습니다. CloudWatch Logs Insights에서 이 예를 사용하는 경우 *monitorName*을 자신의 모니터 이름으로 바꾸세요.

**트래픽 최적화 제안 보기**

Internet Monitor의 **트래픽 인사이트** 탭에서 위치별로 필터링된 트래픽 최적화 제안을 볼 수 있습니다. 해당 탭의 **트래픽 최적화 제안** 섹션에 표시되는 것과 동일한 정보를 보려면 위치 세분성 필터를 사용하지 않고 다음 CloudWatch Logs Insights 쿼리를 사용하세요.

1. AWS Management Console에서 CloudWatch Logs Insights로 이동합니다.

1. **Log Group**(로그 그룹)에서 `/aws/internet-monitor/monitorName/byCity`와 `/aws/internet-monitor/monitorName/byCountry`를 선택한 다음 시간 범위를 지정합니다.

1. 다음 쿼리를 추가하고 실행합니다.

```
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로 이동합니다.

1. **Log Group**(로그 그룹)에서 `/aws/internet-monitor/monitorName/byCity`와 `/aws/internet-monitor/monitorName/byCountry`를 선택한 다음 시간 범위를 지정합니다.

1. 다음 쿼리를 추가하고 실행합니다.

이 쿼리는 선택한 기간 동안 일리노이주 시카고에 있는 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를 사용한 로그 분석](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AnalyzingLogData.html)을 참조하세요.