

# ALB 연결 로그용 테이블 생성
<a name="create-alb-connection-logs-table"></a>

1. 다음 예제 `CREATE TABLE` 문을 복사하여 Athena 콘솔의 쿼리 편집기에 붙여넣은 다음 자체 로그 항목 요구 사항에 필요한 대로 수정합니다. Athena 콘솔 시작하기에 대한 자세한 내용은 [시작하기](getting-started.md) 섹션을 참조하세요. `LOCATION` 절의 경로를 Amazon S3 연결 로그 폴더의 위치로 바꿉니다. 연결 로그 파일 위치에 대한 자세한 내용은 **Application Load Balancer 사용 설명서의 [연결 로그 파일](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-connection-logs.html#connection-log-file-format)을 참조하세요. 각 로그 파일 필드에 대한 자세한 내용은 [연결 로그 항목](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-connection-logs.html#connection-log-entry-format)을 참조하세요.

   ```
   CREATE EXTERNAL TABLE IF NOT EXISTS alb_connection_logs (
            time string,
            client_ip string,
            client_port int,
            listener_port int,
            tls_protocol string,
            tls_cipher string,
            tls_handshake_latency double,
            leaf_client_cert_subject string,
            leaf_client_cert_validity string,
            leaf_client_cert_serial_number string,
            tls_verify_status string,
            conn_trace_id string
            ) 
            ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'
            WITH SERDEPROPERTIES (
            'serialization.format' = '1',
            'input.regex' =
             '([^ ]*) ([^ ]*) ([0-9]*) ([0-9]*) ([A-Za-z0-9.-]*) ([^ ]*) ([-.0-9]*) \"([^\"]*)\" ([^ ]*) ([^ ]*) ([^ ]*) ?([^ ]*)?( .*)?'
            )
            LOCATION 's3://amzn-s3-demo-bucket/connection-log-folder-path/'
   ```

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