

# CloudFront 실시간 로그용 테이블 생성
<a name="create-cloudfront-table-real-time-logs"></a>

**CloudFront 실시간 로그 파일 필드의 테이블 생성**

1. 다음 예제 DDL 문을 복사하여 Athena 콘솔의 쿼리 편집기에 붙여 넣습니다. 예제 문에서는 **Amazon CloudFront 개발자 안내서의 [실시간 로그](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/real-time-logs.html) 섹션에 설명된 로그 파일 필드를 사용합니다. 로그를 저장하는 Amazon S3 버킷의 `LOCATION`을 수정합니다. 쿼리 편집기 사용에 대한 자세한 내용은 [시작하기](getting-started.md) 단원을 참조하세요.

   이 쿼리는 `ROW FORMAT DELIMITED` 및 `FIELDS TERMINATED BY '\t'`를 지정하여 필드가 탭 문자로 구분됨을 나타냅니다. `ROW FORMAT DELIMITED`의 경우 Athena는 기본적으로 [LazySimpleSerDe](lazy-simple-serde.md)를 사용합니다. `timestamp` 열은 Athena에서 예약어이기 때문에 백틱(`) 키를 사용하여 이스케이프됩니다. 자세한 내용은 [쿼리에서 예약어 이스케이프](reserved-words.md) 섹션을 참조하세요.

   다음 예제에는 사용 가능한 모든 필드가 포함되어 있습니다. 필요하지 않은 필드를 주석 처리하거나 제거할 수 있습니다.

   ```
   CREATE EXTERNAL TABLE IF NOT EXISTS cloudfront_real_time_logs ( 
   `timestamp` STRING,
   c_ip STRING,
   time_to_first_byte BIGINT,
   sc_status BIGINT,
   sc_bytes BIGINT,
   cs_method STRING,
   cs_protocol STRING,
   cs_host STRING,
   cs_uri_stem STRING,
   cs_bytes BIGINT,
   x_edge_location STRING,
   x_edge_request_id STRING,
   x_host_header STRING,
   time_taken BIGINT,
   cs_protocol_version STRING,
   c_ip_version STRING,
   cs_user_agent STRING,
   cs_referer STRING,
   cs_cookie STRING,
   cs_uri_query STRING,
   x_edge_response_result_type STRING,
   x_forwarded_for STRING,
   ssl_protocol STRING,
   ssl_cipher STRING,
   x_edge_result_type STRING,
   fle_encrypted_fields STRING,
   fle_status STRING,
   sc_content_type STRING,
   sc_content_len BIGINT,
   sc_range_start STRING,
   sc_range_end STRING,
   c_port BIGINT,
   x_edge_detailed_result_type STRING,
   c_country STRING,
   cs_accept_encoding STRING,
   cs_accept STRING,
   cache_behavior_path_pattern STRING,
   cs_headers STRING,
   cs_header_names STRING,
   cs_headers_count BIGINT,
   primary_distribution_id STRING,
   primary_distribution_dns_name STRING,
   origin_fbl STRING,
   origin_lbl STRING,
   asn STRING
   )
   ROW FORMAT DELIMITED 
   FIELDS TERMINATED BY '\t'
   LOCATION 's3://amzn-s3-demo-bucket/'
   TBLPROPERTIES ( 'skip.header.line.count'='2' )
   ```

1. Athena 콘솔에서 쿼리를 실행합니다. 쿼리가 완료된 후 Athena는 `cloudfront_real_time_logs` 테이블을 등록하여 쿼리를 실행할 수 있도록 데이터를 준비합니다.