

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用遮罩功能協助保護敏感日誌資料
<a name="mask-sensitive-log-data"></a>

您可以使用日誌群組*資料保護政策*，協助保護 CloudWatch Logs 擷取的敏感資料。這些政策可讓您稽核和遮罩出現在帳戶中日誌群組擷取之日誌事件中的敏感資料。

建立資料保護政策後，預設為會在所有出口點遮罩與您選取的資料識別符相符的敏感資料，包括 CloudWatch Logs Insights、指標篩選條件和訂閱篩選條件。只有具有 `logs:Unmask` IAM 許可的使用者才能檢視未遮罩的資料。

您可以為帳戶中的所有日誌群組建立資料保護政策，也可以為個別日誌群組建立資料保護政策。當您為整個帳戶建立政策時，它會套用至現有的日誌群組和未來建立的日誌群組。

如果您為整個帳戶建立資料保護政策，並且也為單一日誌群組建立政策，則這兩個政策都會套用至該日誌群組。在任一政策中指定的所有受管資料識別符都會在該日誌群組中進行稽核和遮罩。

**注意**  
標準和不常存取日誌類別中的日誌群組都支援遮罩敏感資料。如需日誌類別的詳細資訊，請參閱 [日誌類別](CloudWatch_Logs_Log_Classes.md)。

每個日誌群組只能有一個日誌群組層級資料保護政策，但該政策可以指定許多受管資料識別符來稽核和遮罩。資料保護政策的限制為 30,720 個字元。

**重要**  
將敏感資料擷取至日誌群組時，系統會偵測這些資料並加以遮罩。系統不會遮罩在您設定資料保護政策之前擷取至日誌群組的日誌事件。

CloudWatch Logs 支援許多*受管資料識別符*，提供預先設定的資料類型，您可以選擇這些資料類型來保護財務資料、個人健康資訊 (PHI) 和個人身分識別資訊 (PII)。CloudWatch Logs 資料保護功能可讓您利用模式比對和機器學習模型來偵測敏感資料。對於某些類型的受管資料識別符，偵測還取決於尋找與敏感資料相鄰的特定關鍵字。您也可以使用自訂資料識別符來建立針對特定使用案例量身打造的資料識別符。

當偵測到符合您所選取資料識別碼的敏感資料時，就會向 CloudWatch 發出指標。這是 **LogEventsWithFindings** 指標，其在 **AWS/Logs** 命名空間中發出。您可以使用此指標建立 CloudWatch 警示，並且可以在圖形和儀表板中將其視覺化。資料保護發出的指標是付費指標，但在此免費提供。如需有關 CloudWatch Logs 傳送至 CloudWatch 之指標的詳細資訊，請參閱 [使用 CloudWatch 指標監控使用量](CloudWatch-Logs-Monitoring-CloudWatch-Metrics.md)。

每個受管資料識別符旨在偵測特定類型的敏感資料，例如特定國家或地區的信用卡號碼、 AWS 私密存取金鑰或護照號碼。建立資料保護政策時，您可以將 CloudWatch Logs 設定為使用這些識別符，來分析由日誌群組擷取的日誌，並在偵測到日誌時採取動作。

CloudWatch Logs 資料保護功能可以使用受管資料識別符，偵測下列類別的敏感資料：
+ 登入資料，例如私有金鑰或 AWS 私密存取金鑰 
+ 財務資訊，例如信用卡號碼。
+ 個人身分識別資訊 (PII)，例如駕照或社會安全號碼
+ 受保護醫療資訊 (PHI)，例如健康保險或醫療識別號碼
+ 裝置識別符，例如 IP 地址或 MAC 地址

如需有關可保護之資料類型的詳細資訊，請參閱[您可以保護的資料類型](protect-sensitive-log-data-types.md)。

**Contents**
+ [了解資料保護政策](cloudwatch-logs-data-protection-policies.md)
  + [什麼是資料保護政策？](cloudwatch-logs-data-protection-policies.md#what-are-data-protection-policies)
  + [資料保護政策的結構如何？](cloudwatch-logs-data-protection-policies.md#overview-of-data-protection-policies)
    + [資料保護政策的 JSON 屬性](cloudwatch-logs-data-protection-policies.md#data-protection-policy-json-properties)
    + [政策陳述式的 JSON 屬性](cloudwatch-logs-data-protection-policies.md#policy-statement-json-properties)
    + [政策陳述式操作的 JSON 屬性](cloudwatch-logs-data-protection-policies.md#statement-operation-json-properties)
+ [必須具備 IAM 許可才能建立或使用資料保護政策](data-protection-policy-permissions.md)
  + [帳戶層級資料保護政策所需的許可](data-protection-policy-permissions.md#data-protection-policy-permissions-accountlevel)
  + [單一日誌群組之資料保護政策所需的許可](data-protection-policy-permissions.md#data-protection-policy-permissions-loggroup)
  + [資料保護政策範例](data-protection-policy-permissions.md#data-protection-policy-sample)
+ [建立帳戶層級資料保護政策](mask-sensitive-log-data-accountlevel.md)
  + [主控台](mask-sensitive-log-data-accountlevel.md#mask-sensitive-log-data-accountlevel-console)
  + [AWS CLI](mask-sensitive-log-data-accountlevel.md#mask-sensitive-log-data-accountlevel-cli)
    + [AWS CLI 或 API 操作的資料保護政策語法](mask-sensitive-log-data-accountlevel.md#mask-sensitive-log-data-policysyntax-account)
+ [建立單一日誌群組的資料保護政策](mask-sensitive-log-data-start.md)
  + [主控台](mask-sensitive-log-data-start.md#mask-sensitive-log-data-start-console)
  + [AWS CLI](mask-sensitive-log-data-start.md#mask-sensitive-log-data-start-cli)
    + [AWS CLI 或 API 操作的資料保護政策語法](mask-sensitive-log-data-start.md#mask-sensitive-log-data-policysyntax)
+ [檢視未遮罩的資料](mask-sensitive-log-data-viewunmasked.md)
+ [稽核問題清單報告](mask-sensitive-log-data-audit-findings.md)
  + [將稽核問題清單傳送至受 保護的 儲存貯體所需的金鑰政策 AWS KMS](mask-sensitive-log-data-audit-findings.md#mask-sensitive-log-data-audit-findings-kms)
+ [您可以保護的資料類型](protect-sensitive-log-data-types.md)
  + [適用於敏感資料類型的 CloudWatch Logs 受管資料識別符](CWL-managed-data-identifiers.md)
    + [憑證](protect-sensitive-log-data-types-credentials.md)
      + [憑證資料類型的資料識別符 ARN](protect-sensitive-log-data-types-credentials.md#cwl-data-protection-credentials-arns)
    + [裝置識別符](protect-sensitive-log-data-types-device.md)
      + [裝置資料類型的資料識別符 ARN](protect-sensitive-log-data-types-device.md#cwl-data-protection-devices-arns)
    + [財務資訊](protect-sensitive-log-data-types-financial.md)
      + [財務資料類型的資料識別符 ARN](protect-sensitive-log-data-types-financial.md#cwl-data-protection-financial-arns)
    + [受保護醫療資訊 (PHI)](protect-sensitive-log-data-types-health.md)
      + [受保護醫療資訊 (PHI) 資料類型的資料識別符 ARN](protect-sensitive-log-data-types-health.md#cwl-data-protection-phi-arns)
    + [個人身分識別資訊 (PII)](protect-sensitive-log-data-types-pii.md)
      + [駕照識別號碼的關鍵字](protect-sensitive-log-data-types-pii.md#CWL-managed-data-identifiers-pii-dl-keywords)
      + [國民身分證號碼的關鍵字](protect-sensitive-log-data-types-pii.md#CWL-managed-data-identifiers-pii-natlid-keywords)
      + [護照號碼的關鍵字](protect-sensitive-log-data-types-pii.md#CWL-managed-data-identifiers-pii-passport-keywords)
      + [納稅識別號碼及參考號碼的關鍵字](protect-sensitive-log-data-types-pii.md#CWL-managed-data-identifiers-financial-tin-keywords)
      + [個人身分識別資訊 (PII) 的資料識別符 ARN](protect-sensitive-log-data-types-pii.md#CWL-data-protection-pii-arns)
  + [自訂資料識別符](CWL-custom-data-identifiers.md)
    + [什麼是 SNS 自訂資料識別符？](CWL-custom-data-identifiers.md#what-are-custom-data-identifiers)
    + [自訂資料識別符的限制](CWL-custom-data-identifiers.md#custom-data-identifiers-constraints)
    + [在主控台中使用自訂資料識別符](CWL-custom-data-identifiers.md#using-custom-data-identifiers-console)
    + [在您的資料保護政策中使用自訂資料識別符](CWL-custom-data-identifiers.md#using-custom-data-identifiers)