

 Amazon Redshift는 패치 198부터 새 Python UDF 생성을 더 이상 지원하지 않습니다. 기존 Python UDF는 2026년 6월 30일까지 계속 작동합니다. 자세한 내용은 [블로그 게시물](https://aws.amazon.com/blogs/big-data/amazon-redshift-python-user-defined-functions-will-reach-end-of-support-after-june-30-2026/)을 참조하세요.

# Amazon Redshift의 로깅 및 모니터링
<a name="security-incident-response"></a>

모니터링은 Amazon Redshift와 AWS 솔루션의 안정성, 가용성 및 성능을 유지하는 데 중요한 부분입니다. 다중 지점 실패가 발생할 경우 보다 쉽게 디버깅할 수 있도록 AWS 솔루션의 모든 부분으로부터 모니터링 데이터를 수집할 수 있습니다. AWS는 Amazon Redshift 리소스를 모니터링하고 잠재적 인시던트에 대응하기 위한 여러 도구를 제공합니다.

**Amazon CloudWatch 경보**  
Amazon CloudWatch 경보를 사용하면 지정한 기간 동안 단일 지표를 감시합니다. 지표가 지정된 임계값을 초과하면 Amazon SNS 주제 또는 AWS Auto Scaling 정책으로 알림이 전송됩니다. CloudWatch 경보는 단순히 특정 상태에 있다고 해서 작업을 호출하지 않습니다. 대신, 상태가 변경되어 지정된 기간 동안 유지되어야 합니다. 자세한 내용은 [경보 생성](performance-metrics-alarms.md) 섹션을 참조하세요. 지표 목록은 [Amazon Redshift의 성능 데이터](metrics-listing.md) 단원을 참조하십시오.

**AWS CloudTrail 로그**  
CloudTrail은 Amazon Redshift에서 사용자, IAM 역할 또는 AWS 서비스가 수행한 API 작업에 대한 레코드를 제공합니다. CloudTrail에서 수집한 정보를 사용하여 Amazon Redshift에 수행된 요청, 요청이 수행된 IP 주소, 요청을 수행한 사람, 요청이 수행된 시간 및 추가 세부 정보를 확인할 수 있습니다. 자세한 내용은 [CloudTrail을 사용하여 로깅](logging-with-cloudtrail.md) 섹션을 참조하세요.

# 데이터베이스 감사 로깅
<a name="db-auditing"></a>

Amazon Redshift는 연결 및 사용자 작업에 대한 정보를 데이터베이스에 기록합니다. 이렇게 기록되는 로그는 보안 및 문제 해결을 목적으로 데이터베이스를 모니터링하는 데 효과적입니다. 이러한 프로세스를 *데이터베이스 감사*라고 합니다. 로그는 다음 위치에 저장할 수 있습니다.
+ *Amazon S3 버킷* - 데이터베이스의 모니터링 작업을 담당하는 사용자를 위해 데이터 보안 기능으로 편리하게 액세스할 수 있습니다.
+ *Amazon CloudWatch* - 시각화 기능 및 설정 작업과 같은 CloudWatch에 내장된 기능을 사용하여 감사 로깅 데이터를 볼 수 있습니다.

**참고**  
[SYS\$1CONNECTION\$1LOG](https://docs.aws.amazon.com/redshift/latest/dg/SYS_CONNECTION_LOG.html)는 Amazon Redshift Serverless에 대한 연결 로그 데이터를 수집합니다.  Amazon Redshift Serverless에 대한 감사 로깅 데이터를 수집할 때는 로그 파일로 전송할 수 없으며 CloudWatch로만 전송할 수 있다는 점에 유의하세요.

**Topics**
+ [

## Amazon Redshift 로그
](#db-auditing-logs)
+ [

## 감사 로그 및 Amazon CloudWatch
](#db-auditing-cloudwatch-provisioned)
+ [

# 감사 로깅 활성화
](db-auditing-console.md)
+ [

# 보안 로깅
](db-auditing-secure-logging.md)

## Amazon Redshift 로그
<a name="db-auditing-logs"></a>

Amazon Redshift는 다음 로그 파일에 정보를 로그합니다.
+ *연결 로그(Connection log)* - 인증 시도 횟수와 연결 및 연결 해제 정보를 로그합니다.
+ *사용자 로그(User log)* - 데이터베이스 사용자 정의 변경 사항에 대한 정보를 로그합니다.
+ *사용자 작업 로그(User activity log)* - 데이터베이스에서 실행하기 전에 각 쿼리를 로그합니다.

연결 및 사용자 로그는 주로 보안 목적으로 사용하기 좋습니다. 연결 로그를 사용하여 데이터베이스에 연결 중인 사용자에 대한 정보와 관련 연결 정보를 모니터링할 수 있습니다. 이 정보는 IP 주소, 요청한 시기, 사용한 인증 유형 등이 될 수 있습니다. 그리고 사용자 로그는 데이터베이스 사용자의 정의 변경 여부를 모니터링하는 데 사용됩니다.

사용자 작업 로그는 주로 문제 해결 목적으로 사용하기 좋습니다. 이 로그는 사용자와 시스템 모두 데이터베이스에서 실행하는 쿼리 유형에 대한 정보를 추적합니다.

연결 로그와 사용자 로그는 모두 데이터베이스의 시스템 테이블에 저장되는 정보와 일치합니다. 따라서 시스템 테이블을 사용해 동일한 정보를 얻을 수도 있지만 로그 파일이 가져오거나 살펴보는 데 더욱 간단한 메커니즘을 가지고 있습니다. 로그 파일은 데이터베이스 권한이 아닌 Amazon S3 권한을 이용하여 테이블에 대한 쿼리를 실행합니다. 또한 시스템 테이블에 대해 쿼리를 실행하기보다는 로그 파일의 정보를 확인하여 데이터베이스에 미치는 영향을 최소화합니다.

**참고**  
로그 파일은 시스템 로그 테이블인 [STL\$1USERLOG](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_USERLOG.html) 및 [STL\$1CONNECTION\$1LOG](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_CONNECTION_LOG.html)만큼 최신 상태가 아닙니다. 최신 레코드를 제외하고 이보다 오래된 레코드를 로그 파일에 복사하였습니다.

**참고**  
Amazon Redshift Serverless의 경우 [SYS\$1CONNECTION\$1LOG](https://docs.aws.amazon.com/redshift/latest/dg/SYS_CONNECTION_LOG.html)는 연결 로그 데이터를 수집합니다. Amazon Redshift Serverless에 대한 감사 로깅 데이터를 수집할 때는 로그 파일로 전송할 수 없으며 CloudWatch로만 전송할 수 있다는 점에 유의하세요.

### 연결 로그
<a name="db-auditing-connection-log"></a>

인증 시도 횟수와 연결 및 차단 정보를 기록합니다. 다음 표는 연결 로그에 기록되는 정보를 설명한 것입니다. 이러한 필드에 대한 자세한 내용은 *Amazon Redshift 데이터베이스 개발자 안내서*의 [STL\$1CONNECTION\$1LOG](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_CONNECTION_LOG.html)를 참조하세요. 수집된 Amazon Redshift Serverless의 연결 로그 데이터에 대한 자세한 내용은 [SYS\$1CONNECTION\$1LOG](https://docs.aws.amazon.com/redshift/latest/dg/SYS_CONNECTION_LOG.html)를 참조하세요.

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/redshift/latest/mgmt/db-auditing.html)

### 사용자 로그
<a name="db-auditing-user-log"></a>

 다음과 같이 데이터베이스 사용자의 변경 사항에 대한 세부 정보를 기록합니다.
+ 사용자 생성
+ 사용자 삭제
+ 사용자 변경(이름 변경)
+ 사용자 변경(속성 변경)

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/redshift/latest/mgmt/db-auditing.html)

사용자 변경 사항에 대한 추가 정보를 찾으려면 [SYS\$1USERLOG](https://docs.aws.amazon.com/redshift/latest/dg/SYS_USERLOG.html) 시스템 뷰를 쿼리합니다. 이 뷰에는 Amazon Redshift Serverless의 로그 데이터가 포함되어 있습니다.

### 사용자 작업 로그
<a name="db-auditing-user-activity-log"></a>

데이터베이스에서 실행하기 전에 각 쿼리를 기록합니다.

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/redshift/latest/mgmt/db-auditing.html)

## 감사 로그 및 Amazon CloudWatch
<a name="db-auditing-cloudwatch-provisioned"></a>

 Amazon Redshift에서는 감사 로깅이 기본적으로 설정되어 있지 않습니다. 클러스터에서 로깅을 설정하면 Amazon Redshift가 로그를 생성한 후 Amazon S3으로 업로드합니다. 이 로그는 감사 로깅이 사용된 시점부터 현재까지 데이터를 로그에 수집합니다. 각 로깅 업데이트는 이전 로그의 연속입니다.

CloudWatch 또는 Amazon S3에 업로드되는 감사 로깅은 수동 프로세스(옵션)입니다. 시스템 테이블로 업로드되는 로깅은 옵션이 아니며 자동으로 실행됩니다. 시스템 테이블에 로깅에 대한 자세한 내용은 Amazon Redshift 데이터베이스 개발자 안내서의 [시스템 테이블 참조](https://docs.aws.amazon.com/redshift/latest/dg/cm_chap_system-tables.html)를 참조하세요.

연결 로그, 사용자 로그 및 사용자 작업 로그는 모두 AWS Management Console, Amazon Redshift API Reference 또는 AWS Command Line Interface(AWS CLI)에서 사용됩니다. 사용자 작업 로그의 경우에는 `enable_user_activity_logging` 데이터베이스 파라미터도 활성화해야 합니다. 연결된 파라미터를 제외하고 감사 로깅 기능만 활성화하면 데이터베이스 감사 로그가 사용자 작업 로그를 제외한 연결 로그와 사용자 로그 정보만 기록합니다. `enable_user_activity_logging` 파라미터는 기본적으로 활성화되어 있지 않습니다(`false`). `true`로 설정하여 사용자 활동 로그를 활성화하도록 할 수 있습니다. 자세한 내용은 [Amazon Redshift 파라미터 그룹](working-with-parameter-groups.md) 섹션을 참조하세요.

CloudWatch에 대한 로깅을 활성화하면 Amazon Redshift가 클러스터 연결, 사용자 및 사용자 활동 로그 데이터를 Amazon CloudWatch Logs 로그 그룹으로 내보냅니다. 스키마 측면에서 로그 데이터는 변경되지 않습니다. CloudWatch는 애플리케이션 모니터링을 위해 구축되었으며, 이를 사용하여 실시간 분석을 수행하거나 조치를 취하도록 설정할 수 있습니다. Amazon CloudWatch Logs를 사용하여 내구성이 우수한 스토리지에 로그 레코드를 저장할 수 있습니다.

Amazon S3 로그 파일을 저장하는 대신 CloudWatch를 사용하여 로그를 보는 것이 좋습니다. 구성이 많이 필요하지 않으며 모니터링 요구 사항에 맞을 수 있습니다. 특히 이미 다른 서비스 및 애플리케이션을 모니터링하는 데 사용하는 경우 더욱 그렇습니다.

### Amazon CloudWatch Logs의 로그 그룹 및 로그 이벤트
<a name="db-auditing-cloudwatch-provisioned-log-group"></a>

내보낼 Amazon Redshift 로그를 선택한 후 Amazon CloudWatch Logs에서 로그 이벤트를 모니터링할 수 있습니다. 다음 접두사 아래에 Amazon Redshift Serverless에 대한 새 로그 그룹이 자동으로 생성됩니다. 여기서 `log_type`은 로그 유형을 나타냅니다.

```
/aws/redshift/cluster/<cluster_name>/<log_type>
```

예를 들어 연결 로그 내보내기를 선택하면 로그 데이터는 다음 로그 그룹에 저장됩니다.

```
/aws/redshift/cluster/cluster1/connectionlog
```

로그 이벤트는 로그 스트림을 사용하여 로그 그룹으로 내보내집니다. 서버리스 엔드포인트에 대한 로그 이벤트 내에서 정보를 검색하려면 CloudWatch Logs 콘솔, AWS CLI 또는 Amazon CloudWatch Logs API를 사용합니다. 로그 데이터 검색 및 필터링에 대한 자세한 내용은 [필터를 사용하여 로그 이벤트에서 지표 생성](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/MonitoringLogData.html)을 참조하세요.

CloudWatch에서는 세분성과 유연성을 제공하는 쿼리 구문을 사용하여 로그 데이터를 검색할 수 있습니다. 자세한 내용은 [CloudWatch Logs Insights 쿼리 구문](https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/CWL_QuerySyntax.html)을 참조하세요.

### Amazon CloudWatch 감사 로깅으로 마이그레이션
<a name="db-auditing-cloudwatch-provisioned-migration"></a>

Amazon S3으로 로그를 전송하고 구성을 변경하는 경우(예: 로그를 CloudWatch로 전송하도록 변경) Amazon S3에 남아 있는 로그는 영향을 받지 않습니다. 로그 데이터가 있는 Amazon S3 버킷에서 계속 쿼리할 수 있습니다.

### Amazon S3의 로그 파일
<a name="db-auditing-manage-log-files"></a>

Amazon S3에서 Amazon Redshift 로그 파일의 수와 크기는 클러스터의 작업에 커다란 영향을 미칩니다. 다수의 로그를 생성하는 활성 클러스터가 하나 있다고 가정할 때 Amazon Redshift가 더욱 빈번하게 로그 파일을 생성할 수 있습니다. 같은 시간에 다수의 연결 로그가 만들어지는 등 동일한 유형의 작업에 대한 로그 파일이 연이어 생성되기도 합니다.

Amazon Redshift가 Amazon S3을 사용하여 로그를 저장하면 Amazon S3에서 사용하는 스토리지에 대한 요금이 발생합니다. Amazon S3에 대한 로깅을 구성하기 전에 로그 파일을 저장하는 데 걸리는 시간을 계획해야 합니다. 이 과정에서 감사 요구에 따라 로그 파일을 삭제하거나 보관할 수 있는 시기를 결정합니다. 저장 기간에 대한 계획은 규정 준수 또는 규제 요건에 관한 데이터처럼 저장하는 데이터 유형에 따라 크게 달라집니다. Amazon S3 요금에 대한 자세한 내용은 [Amazon Simple Storage Service(S3) 요금](https://aws.amazon.com/s3/pricing/)을 참조하세요.

#### Amazon S3에 로깅을 활성화할 때의 제한
<a name="db-auditing-enable-logging-limitations"></a>

감사 로깅은 다음과 같은 제약이 있습니다.
+ Amazon S3 관리형 키(SSE-S3) 암호화(AES-256)만 사용할 수 있습니다.
+ Amazon S3 버킷에 S3 객체 잠금 기능이 해제되어 있어야 합니다.

#### Amazon Redshift 감사 로깅을 위한 버킷 권한
<a name="db-auditing-bucket-permissions"></a>

Amazon S3에 대한 로깅을 설정하면 Amazon Redshift가 로깅 정보를 수집한 후 Amazon S3에 저장된 로그 파일로 업로드합니다. 기존 버킷이나 새 버킷을 사용할 수 있습니다. Amazon Redshift에는 버킷에 대한 다음 IAM 권한이 필요합니다.
+ `s3:GetBucketAcl` 이 서비스는 버킷 소유자 식별을 위해 Amazon S3 버킷에 대한 읽기 권한이 필요합니다.
+ `s3:PutObject` 이 서비스는 로그 업로드를 위해 객체 업로드 권한이 필요합니다. 또한 로깅을 사용하는 사용자 또는 IAM 역할에 Amazon S3 버킷에 대한 `s3:PutObject` 권한이 있어야 합니다. 로그가 업로드될 때마다 서비스는 현재 버킷 소유자가 로깅 활성화 시점의 버킷 소유자와 일치하는지 확인합니다. 이러한 소유자가 일치하지 않으면 오류가 발생합니다.

감사 로깅을 사용하도록 설정할 때 새 버킷을 생성하는 옵션을 선택하면 버킷에 올바른 권한이 적용됩니다. 하지만 Amazon S3에서 고유한 버킷을 생성하거나 기존 버킷을 사용하는 경우에는 버킷 이름을 포함하는 버킷 정책을 추가해야 합니다. 로그는 서비스 보안 주체 자격 증명을 사용하여 전달됩니다. 대부분의 AWS 리전의 경우 Redshift 서비스 보안 주체 이름인 *redshift.amazonaws.com*을 추가합니다.

버킷 정책은 다음 형식을 사용합니다. *ServiceName*과 *BucketName*은 값의 자리 표시자입니다. 또한 버킷 정책에서 연결된 작업 및 리소스를 지정합니다.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "Put bucket policy needed for audit logging",
            "Effect": "Allow",
            "Principal": {
                "Service": "ServiceName"
            },
            "Action": [
                "s3:PutObject",
                "s3:GetBucketAcl"
            ],
            "Resource": [
                "arn:aws:s3:::BucketName",
                "arn:aws:s3:::BucketName/*"
            ]
        }
    ]
}
```

------

다음 예는 미국 동부(버지니아 북부) 리전과 `AuditLogs`라는 버킷에 대한 버킷 정책입니다.

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "Put bucket policy needed for audit logging",
            "Effect": "Allow",
            "Principal": {
                "Service": "redshift.amazonaws.com"
            },
            "Action": [
                "s3:PutObject",
                "s3:GetBucketAcl"
            ],
            "Resource": [
                "arn:aws:s3:::AuditLogs",
                "arn:aws:s3:::AuditLogs/*"
            ]
        }
    ]
}
```

------

기본적으로 사용되지 않는 리전('옵트인' 리전이라고도 함)에는 리전별 서비스 보안 주체 이름이 필요합니다. 이러한 경우 서비스 보안 주체 이름에는 `redshift.region.amazonaws.com` 형식으로 리전이 포함됩니다. 아시아 태평양(홍콩) 리전의 *redshift.ap-east-1.amazonaws.com*을 예로 들 수 있습니다. 기본적으로 활성화되어 있지 않은 리전의 목록은 *AWS 일반 참조*의 [AWS 리전 관리](https://docs.aws.amazon.com/general/latest/gr/rande-manage.html)를 참조하세요.

**참고**  
리전별 서비스 보안 주체 이름은 클러스터가 위치한 리전과 일치합니다.

##### 로그 파일에 대한 모범 사례
<a name="db-auditing-bucket-permissions-confused-deputy"></a>

 Redshift가 Amazon S3에 로그 파일을 업로드할 때 대용량 파일을 부분적으로 업로드할 수 있습니다. 멀티파트 업로드에 실패하면 파일의 일부가 Amazon S3 버킷에 남아 있을 수 있습니다. 이로 인해 추가 스토리지 비용이 발생할 수 있으므로 멀티파트 업로드가 실패할 때 어떤 일이 발생하는지 이해하는 것이 중요합니다. 감사 로그의 멀티파트 업로드에 대한 자세한 설명은 [멀티파트 업로드를 사용하여 객체 업로드 및 복사](https://docs.aws.amazon.com/AmazonS3/latest/userguide/mpuoverview.html)와 [멀티파트 업로드 중단](https://docs.aws.amazon.com/AmazonS3/latest/userguide/abort-mpu.html)을 참조하세요.

S3 버킷 생성 및 버킷 정책 추가에 대한 자세한 내용은 *Amazon Simple Storage Service 사용 설명서*의 [범용 버킷 생성](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html) 및 [Amazon S3의 버킷 정책](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucket-policies.html)을 참조하세요.

#### Amazon Redshift 감사 로깅을 위한 버킷 구조
<a name="db-auditing-bucket-structure"></a>

기본적으로 Amazon Redshift는 다음 버킷 및 객체 구조를 사용하여 Amazon S3 버킷의 로그 파일을 구성합니다. `` 

`AWSLogs/AccountID/ServiceName/Region/Year/Month/Day/AccountID_ServiceName_Region_ClusterName_LogType_Timestamp.gz` 

`AWSLogs/123456789012/redshift/us-east-1/2013/10/29/123456789012_redshift_us-east-1_mycluster_userlog_2013-10-29T18:01.gz`를 예로 들 수 있습니다.

 Amazon S3 키 접두사를 제공하는 경우 접두사를 키 시작 부분에 넣습니다.

예를 들어 접두사로 myprefix를 지정한다면 다음과 같습니다. `myprefix/AWSLogs/123456789012/redshift/us-east-1/2013/10/29/123456789012_redshift_us-east-1_mycluster_userlog_2013-10-29T18:01.gz` 

Amazon S3 키 접두사는 512자를 초과할 수 없습니다. 또한 공백( ), 큰 따옴표("), 작은 따옴표('), 백슬래시(\$1)가 포함되어서도 안 됩니다. 허용되지 않는 특수 문자와 제어 문자도 다수 있습니다. 이러한 문자의 16진수 코드는 다음과 같습니다.
+ x00\$1x20
+ x22
+ x27
+ x5c
+ x7f 이상

### Amazon S3에서 감사 로깅 고려 사항
<a name="db-auditing-failures"></a>

 Amazon Redshift 감사 로깅은 다음과 같은 이유로 중단될 수 있습니다.
+  Amazon Redshift에는 Amazon S3 버킷에 로그를 업로드할 권한이 없습니다. 버킷이 올바른 IAM 정책으로 구성되었는지 확인합니다. 자세한 내용은 [Amazon Redshift 감사 로깅을 위한 버킷 권한](#db-auditing-bucket-permissions) 섹션을 참조하세요.
+  버킷 소유자가 변경된 경우. Amazon Redshift가 로그를 업로드할 때는 버킷 소유자가 로깅 사용 시점의 소유자와 동일한지 확인합니다. 버킷 소유자가 바뀐 경우에는 감사 로깅에 사용할 버킷이 다른 것으로 구성될 때까지 Amazon Redshift가 로그를 업로드하지 못합니다.
+  버킷을 찾을 수 없는 경우. Amazon S3에서 버킷이 삭제되면 Amazon Redshift가 로그를 업로드할 수 없습니다. 이때 버킷을 다시 생성하거나, Amazon Redshift를 구성하여 로그를 다른 버킷으로 업로드해야 합니다.

### AWS CloudTrail을 사용한 API 직접 호출
<a name="rs-db-auditing-cloud-trail"></a>

Amazon Redshift는 Amazon Redshift에서 사용자, 역할 또는 AWS 서비스가 수행한 작업에 대한 레코드를 제공하는 서비스인 AWS CloudTrail과 통합됩니다. CloudTrail은 Amazon Redshift에 대한 모든 API 호출을 이벤트로 캡처합니다. Amazon Redshift와 AWS CloudTrail 통합에 대한 자세한 내용은 [CloudTrail을 사용한 로깅](https://docs.aws.amazon.com/redshift/latest/mgmt/logging-with-cloudtrail.html)을 참조하십시오.

CloudTrail은 Amazon Redshift 데이터베이스 감사 로깅과 별도로 또는 추가로 사용할 수 있습니다.

CloudTrail에 대한 자세한 내용은 [AWS CloudTrail 사용 설명서](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)를 참조하세요.

# 감사 로깅 활성화
<a name="db-auditing-console"></a>

감사 로그 데이터를 내보내도록 Amazon Redshift Redshift를 구성합니다. 로그는 CloudWatch로 내보내거나 Amazon S3 버킷에 파일로 내보낼 수 있습니다.

## 콘솔을 사용한 감사 로깅 활성화
<a name="enable-auditing-logging-task"></a>

### 콘솔 단계
<a name="cluster-audit-logging"></a>

**클러스터에 대한 감사 로깅을 활성화하려면**

1. AWS Management Console에 로그인한 후 [https://console.aws.amazon.com/redshiftv2/](https://console.aws.amazon.com/redshiftv2/)에서 Amazon Redshift 콘솔을 엽니다.

1. 탐색 메뉴에서 **클러스터(Clusters)**를 선택한 후 업그레이드할 클러스터를 선택합니다.

1. **속성** 탭을 선택합니다. **데이터베이스 구성(Database configurations)** 패널에서 **편집(Edit)**을 선택한 다음 **감사 로깅 편집(Edit audit logging)**을 선택합니다.

1. **감사 로깅 편집(Edit audit logging)** 페이지에서 **설정(Turn on)**을 선택하고 **S3 버킷(S3 bucket)** 또는 **CloudWatch**를 선택합니다. 관리가 쉽고 데이터 시각화에 유용한 기능이 있으므로 CloudWatch를 사용하는 것이 좋습니다.

1. 내보낼 로그를 선택합니다.

1. 선택 사항을 저장하려면 **변경 사항 저장(Save changes)**을 선택합니다.

# 보안 로깅
<a name="db-auditing-secure-logging"></a>

Amazon Redshift가 하나 이상의 AWS Glue Data Catalog 뷰를 참조하는 쿼리를 로깅하는 경우, Amazon Redshift는 해당 쿼리에 대한 메타데이터를 로깅할 때 특정 시스템 테이블 및 뷰 열의 필드를 자동으로 마스킹합니다.

보안 로그 마스킹은 마스킹 조건에 맞는 쿼리를 실행하는 동안 Amazon Redshift가 생성하는 모든 시스템 테이블 및 뷰 항목에 적용됩니다. 다음 표에는 텍스트를 `******`로, 숫자를 `-1`로 마스킹하여 보안 로깅이 적용된 시스템 뷰와 열이 나와 있습니다. 텍스트를 마스킹하는 데 사용되는 별표의 수는 원본 텍스트의 문자 수와 일치하며 최대 6자입니다. 6자를 초과하는 문자열은 6개의 별표로 표시됩니다.


****  

| 시스템 테이블 | 중요한 열 | 
| --- | --- | 
| [SYS\$1EXTERNAL\$1QUERY\$1DETAIL](https://docs.aws.amazon.com/redshift/latest/dg/SYS_EXTERNAL_QUERY_DETAIL.html) | **열:** source\$1type, total\$1partitions, qualified\$1partitions, scanned\$1files, returned\$1rows, returned\$1bytes, file\$1format, file\$1location, external\$1query\$1text, warning\$1message | 
| [SYS\$1EXTERNAL\$1QUERY\$1ERROR](https://docs.aws.amazon.com/redshift/latest/dg/SYS_EXTERNAL_QUERY_ERROR.html) | **열:** file\$1location, rowid, column\$1name, original\$1value, modified\$1value, trigger, action, action\$1value, error\$1code | 
| [SYS\$1QUERY\$1DETAIL](https://docs.aws.amazon.com/redshift/latest/dg/SYS_QUERY_DETAIL.html) | **열:** step\$1id, step\$1name, table\$1id, table\$1name, input\$1bytes, input\$1rows, output\$1bytes, output\$1rows, blocks\$1read, blocks\$1write, local\$1read\$1IO, remote\$1read\$1IO, spilled\$1block\$1local\$1disk, spilled\$1block\$1remote\$1disk, step\$1attribute | 
| [SYS\$1QUERY\$1HISTORY](https://docs.aws.amazon.com/redshift/latest/dg/SYS_QUERY_HISTORY.html) | **열:** returned\$1rows, returned\$1bytes | 
| [STL\$1AGGR](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_AGGR.html) | **열**: rows, bytes, tbl, type | 
| [STL\$1BCAST](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_BCAST.html) | **열:** rows, bytes, packets | 
| [STL\$1DDLTEXT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_DDLTEXT.html) | **열:** label, text | 
| [STL\$1DELETE](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_DELETE.html) | **열:** rows, tbl | 
| [STL\$1DIST](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_DIST.html) | **열:** rows, bytes, packets | 
| [STL\$1ERROR](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_ERROR.html) | **열:** file, linenum, context, error | 
| [STL\$1EXPLAIN](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_EXPLAIN.html) | **열:** plannode, info | 
| [STL\$1FILE\$1SCAN](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_FILE_SCAN.html) | **열:** name, line, bytes | 
| [STL\$1HASH](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_HASH.html) | **열:** rows, bytes, tbl, est\$1rows | 
| [STL\$1HASHJOIN](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_HASHJOIN.html) | **열:** rows, tbl, num\$1parts, join\$1type | 
| [STL\$1INSERT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_INSERT.html) | **열:** rows, tbl | 
| [STL\$1LIMIT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_LIMIT.html) | **열:** rows | 
| [STL\$1MERGE](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_MERGE.html) | **열:** rows | 
| [STL\$1MERGEJOIN](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_MERGEJOIN.html) | **열:** rows, tbl | 
| [STL\$1NESTLOOP](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_NESTLOOP.html) | **열:** rows, tbl | 
| [STL\$1PARSE](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_PARSE.html) | **열:** rows | 
| [STL\$1PLAN\$1INFO](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_PLAN_INFO.html) | **열:** startupcost, totalcost, rows, bytes | 
| [STL\$1PROJECT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_PROJECT.html) | **열:** rows, tbl | 
| [STL\$1QUERY](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_QUERY.html) | **열:** querytxt | 
| [STL\$1QUERY\$1METRICS](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_QUERY_METRICS.html) | **열:** max\$1rows, rows, max\$1blocks\$1read, blocks\$1read, max\$1blocks\$1to\$1disk, blocks\$1to\$1disk, max\$1query\$1scan\$1size, query\$1scan\$1size | 
| [STL\$1QUERYTEXT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_QUERYTEXT.html) | **열:** text | 
| [STL\$1RETURN](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_RETURN.html) | **열:** rows, bytes | 
| [STL\$1S3CLIENT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_S3CLIENT.html) | **열:** bucket, key, transfer\$1size, data\$1size | 
| [STL\$1S3CLIENT\$1ERROR](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_S3CLIENT_ERROR.html) | **열:** bucket, key, error, transfer\$1size | 
| [STL\$1SAVE](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_SAVE.html) | **열:** rows, bytes, tbl | 
| [STL\$1SCAN](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_SCAN.html) | **열:** rows, bytes, fetches, type, tbl, rows\$1pre\$1filter, rows\$1pre\$1user\$1filter, perm\$1table\$1name, scanned\$1mega\$1value | 
| [STL\$1SORT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_SORT.html) | **열:** rows, bytes, tbl | 
| [STL\$1SSHCLIENT\$1ERROR](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_SSHCLIENT_ERROR) | **열:** ssh\$1username, endpoint, command, error | 
| [STL\$1TR\$1CONFLICT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_TR_CONFLICT.html) | **열:** table\$1id | 
| [STL\$1UNDONE](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_UNDONE.html) | **열:** table\$1id | 
| [STL\$1UNIQUE](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_UNIQUE.html) | **열:** rows, type, bytes | 
| [STL\$1UTILITYTEXT](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_UTILITYTEXT.html) | **열:** label, text | 
| [STL\$1WINDOW](https://docs.aws.amazon.com/redshift/latest/dg/r_STL_WINDOW.html) | **열:** rows | 
| [STV\$1BLOCKLIST](https://docs.aws.amazon.com/redshift/latest/dg/r_STV_BLOCKLIST.html) | **열:** col, tbl, num\$1values, minvalue, maxvalue | 
| [STV\$1EXEC\$1STATE](https://docs.aws.amazon.com/redshift/latest/dg/r_STV_EXEC_STATE.html) | **열:** rows, bytes, label | 
| [STV\$1INFLIGHT](https://docs.aws.amazon.com/redshift/latest/dg/r_STV_INFLIGHT.html) | **열:** label, text | 
| [STV\$1LOCKS](https://docs.aws.amazon.com/redshift/latest/dg/r_STV_LOCKS.html) | **열:** table\$1id | 
| [STV\$1QUERY\$1METRICS](https://docs.aws.amazon.com/redshift/latest/dg/r_STV_QUERY_METRICS.html) | **열:** rows, max\$1rows, blocks\$1read, max\$1blocks\$1read, max\$1blocks\$1to\$1disk, blocks\$1to\$1disk, max\$1query\$1scan\$1size, query\$1scan\$1size | 
| [STV\$1STARTUP\$1RECOVERY\$1STATE](https://docs.aws.amazon.com/redshift/latest/dg/r_STV_STARTUP_RECOVERY_STATE.html) | **열:** table\$1id, table\$1name | 
| [STV\$1TBL\$1PERM](https://docs.aws.amazon.com/redshift/latest/dg/r_STV_TBL_PERM.html) | **열:** id, name, rows, sorted\$1rows, temp, block\$1count, query\$1scan\$1size | 
| [STV\$1TBL\$1TRANS](https://docs.aws.amazon.com/redshift/latest/dg/r_STV_TBL_TRANS.html) | **열:** id, rows, size | 
| [SVCS\$1EXPLAIN](https://docs.aws.amazon.com/redshift/latest/dg/r_SVCS_EXPLAIN.html) | **열:** plannode, info | 
| [SVCS\$1PLAN\$1INFO](https://docs.aws.amazon.com/redshift/latest/dg/r_SVCS_PLAN_INFO.html) | **열:** rows, bytes | 
| [SVCS\$1QUERY\$1SUMMARY](https://docs.aws.amazon.com/redshift/latest/dg/r_SVCS_QUERY_SUMMARY.html) | **열:** step, rows, bytes, rate\$1row, rate\$1byte, label, rows\$1pre\$1filter | 
| [SVCS\$1S3LIST](https://docs.aws.amazon.com/redshift/latest/dg/r_SVCS_S3LIST.html) | **열:** bucket, prefix, retrieved\$1files, max\$1file\$1size, avg\$1file\$1size | 
| [SVCS\$1S3LOG](https://docs.aws.amazon.com/redshift/latest/dg/r_SVCS_S3LOG.html) | **컬럼:** message | 
| [SVCS\$1S3PARTITION\$1SUMMARY](https://docs.aws.amazon.com/redshift/latest/dg/r_SVCS_S3PARTITION_SUMMARY.html) | **열:** total\$1partitions, qualified\$1partitions, min\$1assigned\$1partitions, max\$1assigned\$1partitions, avg\$1assigned\$1partitions | 
| [SVCS\$1S3QUERY\$1SUMMARY](https://docs.aws.amazon.com/redshift/latest/dg/r_SVCS_S3QUERY_SUMMARY.html) | **열:** external\$1table\$1name, file\$1format, s3\$1scanned\$1rows, s3\$1scanned\$1bytes, s3query\$1returned\$1rows, s3query\$1returned\$1bytes | 
| [SVL\$1QUERY\$1METRICS](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_QUERY_METRICS.html) | **열:** step\$1label, scan\$1row\$1count, join\$1row\$1count, nested\$1loop\$1join\$1row\$1count, return\$1row\$1count, spectrum\$1scan\$1row\$1count, spectrum\$1scan\$1size\$1mb | 
| [SVL\$1QUERY\$1METRICS\$1SUMMARY](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_QUERY_METRICS_SUMMARY.html) | **열:** step\$1label, scan\$1row\$1count, join\$1row\$1count, nested\$1loop\$1join\$1row\$1count, return\$1row\$1count, spectrum\$1scan\$1row\$1count, spectrum\$1scan\$1size\$1mb | 
| [SVL\$1QUERY\$1REPORT](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_QUERY_REPORT.html) | **열:** rows, bytes, label, rows\$1pre\$1filter | 
| [SVL\$1QUERY\$1SUMMARY](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_QUERY_SUMMARY.html) | **열:** rows, bytes, rows\$1pre\$1filter | 
| [SVL\$1S3LIST](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_S3LIST.html) | **열:** bucket, prefix, retrieved\$1files, max\$1file\$1size, avg\$1file\$1size | 
| [SVL\$1S3LOG](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_S3LOG.html) | **컬럼:** message | 
| [SVL\$1S3PARTITION](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_S3PARTITION.html) | **열:** rows, bytes, label, rows\$1pre\$1filter | 
| [SVL\$1S3PARTITION\$1SUMMARY](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_S3PARTITION_SUMMARY.html) | **열:** total\$1partitions, qualified\$1partitions, min\$1assigned\$1partitions, max\$1assigned\$1partitions, avg\$1assigned\$1partitions | 
| [SVL\$1S3QUERY](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_S3QUERY.html) | **열:** external\$1table\$1name, file\$1format, s3\$1scanned\$1rows, s3\$1scanned\$1bytes, s3query\$1returned\$1rows, s3query\$1returned\$1bytes, files | 
| [SVL\$1S3QUERY\$1SUMMARY](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_S3QUERY_SUMMARY.html) | **열:** external\$1table\$1name, file\$1format, s3\$1scanned\$1rows, s3\$1scanned\$1bytes, s3query\$1returned\$1rows, s3query\$1returned\$1bytes | 
| [SVL\$1S3RETRIES](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_S3RETRIES.html) | **열:** file\$1size, location, message | 
| [SVL\$1SPECTRUM\$1SCAN\$1ERROR](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_SPECTRUM_SCAN_ERROR.html) | **열:** location, rowid, colname, original\$1value, modified\$1value, trigger, action, action\$1value, error\$1code | 
| [SVL\$1STATEMENTTEXT](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_STATEMENTTEXT.html) | **열:** type, text | 
| [SVL\$1STORED\$1PROC\$1CALL](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_STORED_PROC_CALL.html) | **열:** querytxt | 
| [SVL\$1STORED\$1PROC\$1MESSAGES](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_STORED_PROC_MESSAGES.html) | **열:** message, linenum, querytext | 
| [SVL\$1UDF\$1LOG](https://docs.aws.amazon.com/redshift/latest/dg/r_SVL_UDF_LOG.html) | **열:** message, funcname | 
| [SVV\$1DISKUSAGE](https://docs.aws.amazon.com/redshift/latest/dg/r_SVV_DISKUSAGE.html) | **열:** name, col, tbl, blocknum, num\$1values, minvalue, maxvalue | 
| [SVV\$1QUERY\$1STATE](https://docs.aws.amazon.com/redshift/latest/dg/r_SVV_QUERY_STATE.html) | **열:** rows, bytes, label | 
| [SVV\$1TABLE\$1INFO](https://docs.aws.amazon.com/redshift/latest/dg/r_SVV_TABLE_INFO.html) | **열:** table\$1id, table | 
| [SVV\$1TRANSACTIONS](https://docs.aws.amazon.com/redshift/latest/dg/r_SVV_TRANSACTIONS.html) | **열:** relation | 

시스템 테이블 및 뷰에 대한 자세한 내용은 *Amazon Redshift 데이터베이스 개발자 안내서*의 [시스템 테이블 및 뷰 참조](https://docs.aws.amazon.com/redshift/latest/dg/cm_chap_system-tables.html)를 참조하세요. 쿼리 결과를 동적으로 마스킹하는 Amazon Redshift의 기능에 대한 자세한 내용은 *Amazon Redshift 데이터베이스 개발자 안내서*의 [ 동적 데이터 마스킹](https://docs.aws.amazon.com/redshift/latest/dg/t_ddm.html)을 참조하세요. Amazon Redshift를 사용하여 AWS Glue Data Catalog에서 뷰를 생성하는 방법에 대한 자세한 내용은 *Amazon Redshift 데이터베이스 개발자 안내서*의 [AWS Glue Data Catalog 뷰](https://docs.aws.amazon.com/redshift/latest/dg/data-catalog-views-overview.html)를 참조하세요.

# CloudTrail을 사용하여 로깅
<a name="logging-with-cloudtrail"></a>

Amazon Redshift, 데이터 공유, Amazon Redshift Serverless, Amazon Redshift Data API 및 쿼리 에디터 v2는 모두 AWS CloudTrail에 통합됩니다. CloudTrail은 Amazon Redshift에서 사용자, 역할 또는 AWS 서비스가 수행한 작업의 레코드를 제공하는 서비스입니다. CloudTrail은 Amazon Redshift에 대한 모든 API 호출을 이벤트로 캡처합니다. 캡처된 호출에는 Redshift 콘솔의 호출과 Redshift 작업에 대한 코드 호출이 포함됩니다.

CloudTrail 추적을 생성하면 Redshift 이벤트를 비롯한 CloudTrail 이벤트를 Amazon S3 버킷에 지속적으로 전달할 수 있습니다. 추적을 구성하지 않은 경우에도 CloudTrail 콘솔의 **이벤트 기록**에서 최신 이벤트를 볼 수 있습니다. CloudTrail에서 수집한 정보를 사용하여 특정 사항을 확인할 수 있습니다. 여기에는 Redshift로 수행한 요청, 요청이 이루어진 IP 주소, 요청 주체, 요청 시점 및 추가 세부 정보가 포함됩니다.

CloudTrail은 Amazon Redshift 데이터베이스 감사 로깅과 별도로 또는 추가로 사용할 수 있습니다.

CloudTrail에 대한 자세한 설명은 [AWS CloudTrail 사용자 가이드](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/)를 참조하십시오.

## CloudTrail의 정보
<a name="working-with-info-in-cloudtrail"></a>

CloudTrail은 계정 생성 시 AWS 계정에서 켜집니다. 활동이 발생하면 해당 활동이 **Event history**(이벤트 기록) 내의 다른 AWS 서비스 이벤트와 함께 CloudTrail 이벤트에 기록됩니다. AWS 계정에서 최신 이벤트를 확인, 검색 및 다운로드할 수 있습니다. 자세한 내용은 *AWS CloudTrail 사용 설명서*에서 [CloudTrail 이벤트 기록을 사용하여 이벤트 보기](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/view-cloudtrail-events.html)를 참조하세요.

Redshift의 이벤트를 포함하여 AWS 계정에 이벤트를 지속적으로 기록하려는 경우 추적을 생성합니다. CloudTrail은 *추적*을 사용하여 Amazon S3 버킷으로 로그 파일을 전송합니다. 콘솔에서 추적을 생성하면 기본적으로 모든 AWS 지역에 추적이 적용됩니다. 추적은 AWS 파티션에 있는 모든 지역의 이벤트를 로깅하고 지정된 Amazon S3 버킷으로 로그 파일을 전송합니다. 또한 CloudTrail 로그에서 수집된 이벤트 데이터를 추가 분석 및 작업하도록 다른 AWS 서비스를 구성할 수 있습니다. 자세한 내용은 *AWS CloudTrail User Guide*의 다음 섹션을 참조하세요.
+ [트레일 생성 개요](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-create-and-update-a-trail.html)
+ [CloudTrail 지원 서비스 및 통합](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-aws-service-specific-topics.html#cloudtrail-aws-service-specific-topics-integrations)
+ [CloudTrail에서 Amazon SNS 알림 구성](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/getting_notifications_top_level.html)
+ [여러 리전으로부터 CloudTrail 로그 파일 받기](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/receive-cloudtrail-log-files-from-multiple-regions.html) 및 [여러 계정으로부터 CloudTrail 로그 파일 받기](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-receive-logs-from-multiple-accounts.html)

모든 Amazon Redshift, Amazon Redshift Serverless, Data API, 데이터 공유 및 쿼리 에디터 v2 작업은 CloudTrail이 로깅합니다. 예를 들어 `AuthorizeDatashare`, `CreateNamespace`, `ExecuteStatement` 및 `CreateConnection` 작업을 호출하면 CloudTrail 로그 파일에 항목이 생성됩니다.

모든 이벤트 또는 로그 항목에는 요청을 생성했던 사용자에 대한 정보가 포함됩니다. 보안 인증 정보를 이용하면 다음을 쉽게 판단할 수 있습니다.
+ 요청을 루트로 했는지 아니면 사용자 자격 증명으로 했는지 여부
+ 역할 또는 페더레이션 사용자에 대한 임시 보안 인증을 사용하여 요청이 생성되었는지 여부.
+ 다른 AWS 서비스에서 요청했는지.

자세한 내용은 *AWS CloudTrail User Guide*의 [CloudTrail userIdentity Element](https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-event-reference-user-identity.html)를 참조하세요.

## 로그 파일 항목
<a name="understanding-cloudtrail-log-files"></a>

*추적*이란 지정한 Amazon S3 버킷에 이벤트를 로그 파일로 입력할 수 있도록 하는 구성입니다. CloudTrail 로그 파일에는 하나 이상의 로그 항목이 포함될 수 있습니다. 이벤트**는 모든 소스로부터의 단일 요청을 나타내며 요청 작업, 작업 날짜와 시간, 요청 파라미터 등에 대한 정보가 들어 있습니다. CloudTrail 로그 파일은 퍼블릭 API 직접 호출의 주문 스택 트레이스가 아니므로 특정 순서로 표시되지 않습니다.

## Amazon Redshift 데이터 공유 예제
<a name="datashare-cloudtrail-example"></a>

다음 예제는 `AuthorizeDataShare` 작업을 보여주는 CloudTrail 로그 항목입니다.

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AKIAIOSFODNN7EXAMPLE:janedoe",
        "arn": "arn:aws:sts::111122223333:user/janedoe",
        "accountId": "111122223333",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "AKIAIOSFODNN7EXAMPLE:janedoe",
                "arn": "arn:aws:sts::111122223333:user/janedoe",
                "accountId": "111122223333",
                "userName": "janedoe"
            },
            "attributes": {
                "creationDate": "2021-08-02T23:40:45Z",
                "mfaAuthenticated": "false"
            }
        }
    },
    "eventTime": "2021-08-02T23:40:58Z",
    "eventSource": "redshift.amazonaws.com",
    "eventName": "AuthorizeDataShare",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "3.227.36.75",
    "userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41", 
    "requestParameters": {
        "dataShareArn": "arn:aws:redshift:us-east-1:111122223333:datashare:4c64c6ec-73d5-42be-869b-b7f7c43c7a53/testshare",
        "consumerIdentifier": "555555555555"
    },
    "responseElements": {
        "dataShareArn": "arn:aws:redshift:us-east-1:111122223333:datashare:4c64c6ec-73d5-42be-869b-b7f7c43c7a53/testshare",
        "producerNamespaceArn": "arn:aws:redshift:us-east-1:123456789012:namespace:4c64c6ec-73d5-42be-869b-b7f7c43c7a53",
        "producerArn": "arn:aws:redshift:us-east-1:111122223333:namespace:4c64c6ec-73d5-42be-869b-b7f7c43c7a53",
        "allowPubliclyAccessibleConsumers": true,
        "dataShareAssociations": [
            {
                "consumerIdentifier": "555555555555",
                "status": "AUTHORIZED",
                "createdDate": "Aug 2, 2021 11:40:56 PM",
                "statusChangeDate": "Aug 2, 2021 11:40:57 PM"
            }
        ]
    },
    "requestID": "87ee1c99-9e41-42be-a5c4-00495f928422",
    "eventID": "03a3d818-37c8-46a6-aad5-0151803bdb09",
    "readOnly": false,
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "111122223333",
    "eventCategory": "Management"
}
```

## Amazon Redshift Serverless 예제
<a name="serverless-cloudtrail-example"></a>

Amazon Redshift Serverless는 Amazon Redshift Serverless에서 수행한 작업의 기록을 제공하기 위해 AWS CloudTrail과 통합됩니다. CloudTrail은 Amazon Redshift Serverless에 대한 모든 API 호출을 이벤트로 캡처합니다. Amazon Redshift Serverless 기능에 대한 자세한 내용은 [Amazon Redshift Serverless 기능 개요](https://docs.aws.amazon.com/redshift/latest/mgmt/serverless-considerations.html)를 참조하십시오.

다음은 `CreateNamespace` 작업을 설명하는 CloudTrail 로그 항목을 보여 주는 예시입니다.

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AAKEOFPINEXAMPLE:admin",
        "arn": "arn:aws:sts::111111111111:assumed-role/admin/admin",
        "accountId": "111111111111",
        "accessKeyId": "AAKEOFPINEXAMPLE",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "AAKEOFPINEXAMPLE",
                "arn": "arn:aws:iam::111111111111:role/admin",
                "accountId": "111111111111",
                "userName": "admin"
            },
            "webIdFederationData": {},
            "attributes": {
                "creationDate": "2022-03-21T20:51:58Z",
                "mfaAuthenticated": "false"
            }
        }
    },
    "eventTime": "2022-03-21T23:15:40Z",
    "eventSource": "redshift-serverless.amazonaws.com",
    "eventName": "CreateNamespace",
    "awsRegion": "us-east-1",
    "sourceIPAddress": "56.23.155.33",
    "userAgent": "aws-cli/2.4.14 Python/3.8.8 Linux/5.4.181-109.354.amzn2int.x86_64 exe/x86_64.amzn.2 prompt/off command/redshift-serverless.create-namespace",
    "requestParameters": {
        "adminUserPassword": "HIDDEN_DUE_TO_SECURITY_REASONS",
        "adminUsername": "HIDDEN_DUE_TO_SECURITY_REASONS",
        "dbName": "dev",
        "namespaceName": "testnamespace"
    },
    "responseElements": {
        "namespace": {
            "adminUsername": "HIDDEN_DUE_TO_SECURITY_REASONS",
            "creationDate": "Mar 21, 2022 11:15:40 PM",
            "defaultIamRoleArn": "",
            "iamRoles": [],
            "logExports": [],
            "namespaceArn": "arn:aws:redshift-serverless:us-east-1:111111111111:namespace/befa5123-16c2-4449-afca-1d27cb40fc99",
            "namespaceId": "8b726a0c-16ca-4799-acca-1d27cb403599",
            "namespaceName": "testnamespace",
            "status": "AVAILABLE"
        }
    },
    "requestID": "ed4bb777-8127-4dae-aea3-bac009999163",
    "eventID": "1dbee944-f889-4beb-b228-7ad0f312464",
    "readOnly": false,
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "111111111111",
    "eventCategory": "Management",
}
```

## Amazon Redshift Data API 예제
<a name="data-api-cloudtrail"></a>

다음은 `ExecuteStatement` 작업을 설명하는 CloudTrail 로그 항목을 보여 주는 예시입니다.

```
{
    "eventVersion":"1.05",
    "userIdentity":{
        "type":"IAMUser",
        "principalId":"AKIAIOSFODNN7EXAMPLE:janedoe",
        "arn":"arn:aws:sts::123456789012:user/janedoe",
        "accountId":"123456789012",
        "accessKeyId":"AKIAI44QH8DHBEXAMPLE",
        "userName": "janedoe"
    },
    "eventTime":"2020-08-19T17:55:59Z",
    "eventSource":"redshift-data.amazonaws.com",
    "eventName":"ExecuteStatement",
    "awsRegion":"us-east-1",
    "sourceIPAddress":"192.0.2.0",
    "userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41",
    "requestParameters":{
        "clusterIdentifier":"example-cluster-identifier",
        "database":"example-database-name",
        "dbUser":"example_db_user_name",
        "sql":"***OMITTED***"
    },
    "responseElements":{
        "clusterIdentifier":"example-cluster-identifier",
        "createdAt":"Aug 19, 2020 5:55:58 PM",
        "database":"example-database-name",
        "dbUser":"example_db_user_name",
        "id":"5c52b37b-9e07-40c1-98de-12ccd1419be7"
    },
    "requestID":"00c924d3-652e-4939-8a7a-cd0612eeb8ac",
    "eventID":"c1fb7076-102f-43e5-9ec9-40820bcc1175",
    "readOnly":false,
    "eventType":"AwsApiCall",
    "recipientAccountId":"123456789012"
}
```

다음 예는 멱등성에 사용된 `clientToken`을 보여주는 `ExecuteStatement` 작업을 보여주는 CloudTrail 로그 항목을 보여줍니다.

```
{
    "eventVersion":"1.05",
    "userIdentity":{
        "type":"IAMUser",
        "principalId":"AKIAIOSFODNN7EXAMPLE:janedoe",
        "arn":"arn:aws:sts::123456789012:user/janedoe",
        "accountId":"123456789012",
        "accessKeyId":"AKIAI44QH8DHBEXAMPLE",
        "userName": "janedoe"
    },
    "eventTime":"2020-08-19T17:55:59Z",
    "eventSource":"redshift-data.amazonaws.com",
    "eventName":"ExecuteStatement",
    "awsRegion":"us-east-1",
    "sourceIPAddress":"192.0.2.0",
    "userAgent":"aws-cli/1.18.118 Python/3.6.10 Linux/4.9.217-0.1.ac.205.84.332.metal1.x86_64 botocore/1.17.41",
    "requestParameters":{
        "clusterIdentifier":"example-cluster-identifier",
        "database":"example-database-name",
        "dbUser":"example_db_user_name",
        "sql":"***OMITTED***",
        "clientToken":"32db2e10-69ac-4534-b3fc-a191052616ce"
    },
    "responseElements":{
        "clusterIdentifier":"example-cluster-identifier",
        "createdAt":"Aug 19, 2020 5:55:58 PM",
        "database":"example-database-name",
        "dbUser":"example_db_user_name",
        "id":"5c52b37b-9e07-40c1-98de-12ccd1419be7"
    },
    "requestID":"00c924d3-652e-4939-8a7a-cd0612eeb8ac",
    "eventID":"c1fb7076-102f-43e5-9ec9-40820bcc1175",
    "readOnly":false,
    "eventType":"AwsApiCall",
    "recipientAccountId":"123456789012"
}
```

## Amazon Redshift 쿼리 에디터 v2 예제
<a name="query-editor-cloudtrail"></a>

다음은 `CreateConnection` 작업을 설명하는 CloudTrail 로그 항목을 보여 주는 예시입니다.

```
{
    "eventVersion": "1.08",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AAKEOFPINEXAMPLE:session",
        "arn": "arn:aws:sts::123456789012:assumed-role/MyRole/session",
        "accountId": "123456789012",
        "accessKeyId": "AKIAI44QH8DHBEXAMPLE",
        "sessionContext": {
            "sessionIssuer": {
                "type": "Role",
                "principalId": "AAKEOFPINEXAMPLE",
                "arn": "arn:aws:iam::123456789012:role/MyRole",
                "accountId": "123456789012",
                "userName": "MyRole"
            },
            "webIdFederationData": {},
            "attributes": {
                "creationDate": "2022-09-21T17:19:02Z",
                "mfaAuthenticated": "false"
            }
        }
    },
    "eventTime": "2022-09-21T22:22:05Z",
    "eventSource": "sqlworkbench.amazonaws.com",
    "eventName": "CreateConnection",
    "awsRegion": "ca-central-1",
    "sourceIPAddress": "192.2.0.2",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0",
    "requestParameters": {
        "password": "***",
        "databaseName": "***",
        "isServerless": false,
        "name": "***",
        "host": "redshift-cluster-2.c8robpbxvbf9.ca-central-1.redshift.amazonaws.com",
        "authenticationType": "***",
        "clusterId": "redshift-cluster-2",
        "username": "***",
        "tags": {
            "sqlworkbench-resource-owner": "AAKEOFPINEXAMPLE:session"
        }
    },
    "responseElements": {
        "result": true,
        "code": "",
        "data": {
            "id": "arn:aws:sqlworkbench:ca-central-1:123456789012:connection/ce56b1be-dd65-4bfb-8b17-12345123456",
            "name": "***",
            "authenticationType": "***",
            "databaseName": "***",
            "secretArn": "arn:aws:secretsmanager:ca-central-1:123456789012:secret:sqlworkbench!7da333b4-9a07-4917-b1dc-12345123456-qTCoFm",
            "clusterId": "redshift-cluster-2",
            "dbUser": "***",
            "userSettings": "***",
            "recordDate": "2022-09-21 22:22:05",
            "updatedDate": "2022-09-21 22:22:05",
            "accountId": "123456789012",
            "tags": {
                "sqlworkbench-resource-owner": "AAKEOFPINEXAMPLE:session"
            },
            "isServerless": false
        }
    },
    "requestID": "9b82f483-9c03-4cdd-bb49-a7009e7da714",
    "eventID": "a7cdd442-e92f-46a2-bc82-2325588d41c3",
    "readOnly": false,
    "eventType": "AwsApiCall",
    "managementEvent": true,
    "recipientAccountId": "123456789012",
    "eventCategory": "Management"
}
```

## AWS CloudTrail 로그의 Amazon Redshift 계정 ID
<a name="cloudtrail-rs-acct-ids"></a>

Amazon Redshift가 다른 AWS 서비스를 호출하면 Amazon Redshift에 속하는 계정 ID로 호출이 기록됩니다. 사용자의 계정 ID로 기록되지는 않습니다. 예를 들어 Amazon Redshift가 `CreateGrant`, `Decrypt`, `Encrypt`, `RetireGrant` 등의 AWS Key Management Service(AWS KMS) 작업을 호출하여 클러스터의 암호화를 관리한다고 가정합니다. 이 경우 호출은 AWS CloudTrail에 의해 Amazon Redshift 계정 ID를 사용하여 기록됩니다.

Amazon Redshift는 다른 AWS 서비스를 호출할 때 다음 표의 계정 ID를 사용합니다.

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ko_kr/redshift/latest/mgmt/logging-with-cloudtrail.html)

다음은 Amazon Redshift가 호출한 AWS KMS Decrypt 작업의 CloudTrail 로그 항목을 보여주는 예입니다.

```
{

    "eventVersion": "1.05",
    "userIdentity": {
        "type": "AssumedRole",
        "principalId": "AROAI5QPCMKLTL4VHFCYY:i-0f53e22dbe5df8a89",
        "arn": "arn:aws:sts::790247189693:assumed-role/prod-23264-role-wp/i-0f53e22dbe5df8a89",
        "accountId": "790247189693",
        "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
        "sessionContext": {
            "attributes": {
                "mfaAuthenticated": "false",
                "creationDate": "2017-03-03T16:24:54Z"
            },
            "sessionIssuer": {
                "type": "Role",
                "principalId": "AROAI5QPCMKLTL4VHFCYY",
                "arn": "arn:aws:iam::790247189693:role/prod-23264-role-wp",
                "accountId": "790247189693",
                "userName": "prod-23264-role-wp"
            }
        }
    },
    "eventTime": "2017-03-03T17:16:51Z",
    "eventSource": "kms.amazonaws.com",
    "eventName": "Decrypt",
    "awsRegion": "us-east-2",
    "sourceIPAddress": "52.14.143.61",
    "userAgent": "aws-internal/3",
    "requestParameters": {
        "encryptionContext": {
            "aws:redshift:createtime": "20170303T1710Z",
            "aws:redshift:arn": "arn:aws:redshift:us-east-2:123456789012:cluster:my-dw-instance-2"
        }
    },
    "responseElements": null,
    "requestID": "30d2fe51-0035-11e7-ab67-17595a8411c8",
    "eventID": "619bad54-1764-4de4-a786-8898b0a7f40c",
    "readOnly": true,
    "resources": [
        {
            "ARN": "arn:aws:kms:us-east-2:123456789012:key/f8f4f94f-e588-4254-b7e8-078b99270be7",
            "accountId": "123456789012",
            "type": "AWS::KMS::Key"
        }
    ],
    "eventType": "AwsApiCall",
    "recipientAccountId": "123456789012",
    "sharedEventID": "c1daefea-a5c2-4fab-b6f4-d8eaa1e522dc"

}
```