收集 AWS 虛擬私有雲流量記錄

剖析器版本:17.0

支援:

本文說明如何使用三種不同方法,將 AWS VPC 流量記錄擷取至 Google Security Operations:Amazon S3 (文字格式)、Amazon CloudWatch Logs with Kinesis Data Firehose,以及 Amazon S3 中的 CSV 格式。AWS VPC Flow Logs 是一項功能,可擷取 VPC 網路介面往來 IP 流量的資訊。整合這項資源後,即可將這些記錄傳送至 Google SecOps 進行分析和監控。

支援的 AWS VPC 流量記錄格式

Google SecOps 支援以兩種主要文字格式擷取 AWS 虛擬私有雲流量記錄:

  • JSON 格式:AWS_VPC_FLOW 記錄類型會剖析 JSON 格式的記錄。在這個格式中,每個記錄項目都包含鍵及其對應的值,因此資料本身就具有說明性。
  • CSV 格式:Google SecOps 也提供 AWS VPC 流量記錄的 CSV 格式剖析器。這個格式只會在標頭列中列出一次欄位鍵,後續各列只會包含以逗號分隔值。

由於 CSV 格式不會在每個記錄項目中加入欄位索引鍵,因此 AWS_VPC_FLOW_CSV 剖析器會依據預先定義的嚴格值順序運作。CSV 檔案必須遵守下列欄位順序,才能正確剖析:

   Version,Account_id,Interface_id,Srcaddr,Dstaddr,Srcport,Dstport,Protocol,Packets,Bytes,Start,End,Action,Log_status,Vpc_id,Subnet_id,Instance_id,Tcp_flags,Type,Pkt_srcaddr,Pkt_dstaddr,Region,Az_id,Sublocation_type,Sublocation_id,Pkt_src_aws_service,Pkt_dst_aws_service,Flow_direction,Traffic_path,Ecs_cluster_arn,Ecs_cluster_name,Ecs_container_instance_arn,Ecs_container_instance_id,Ecs_container_id,Ecs_second_container_id,Ecs_service_name,Ecs_task_definition_arn,Ecs_task_arn,Ecs_task_id

以下是 CSV 記錄行的範例:

   7,369096419186,eni-0520bb5efed19d33a,10.119.32.34,10.119.223.3,51256,16020,6,14,3881,1723542839,1723542871,ACCEPT,OK,vpc-0769a6844ce873a6a,subnet-0cf9b2cb32f49f258,i-088d6080f45f5744f,0,IPv4,10.119.32.34,10.119.223.3,ap-northeast-1,apne1-az4,-,-,-,-,ingress,,-,-,-,-,-,-,-,-,-,-

如果欄位沒有值,請傳遞空值 (例如「, ,」),以維持 CSV 列中的正確位置順序。

事前準備

請確認您已完成下列事前準備事項:

  • Google SecOps 執行個體。
  • AWS 的特殊存取權。

選項 1:使用 AWS S3 (文字格式) 設定 AWS VPC 流量記錄匯出功能

下一節將說明如何設定 Amazon S3 和 Identity and Access Management 權限,以便匯出虛擬私有雲流量記錄,供 Google SecOps 進行分析。

為 Google SecOps 設定 AWS S3 bucket 和 IAM

  1. 按照這份使用手冊的指示建立 Amazon S3 儲存空間:建立儲存空間。
  2. 儲存 bucket 的「名稱」和「區域」,以供日後參考 (例如 aws-vpc-flowlogs)。
  3. 按照這份使用者指南建立使用者:建立 IAM 使用者。
  4. 選取建立的「使用者」。
  5. 選取「安全憑證」分頁標籤。
  6. 在「存取金鑰」部分中,按一下「建立存取金鑰」。
  7. 選取「第三方服務」做為「用途」。
  8. 點選「下一步」。
  9. 選用:新增說明標記。
  10. 按一下「建立存取金鑰」。
  11. 按一下「下載 CSV 檔案」,儲存「存取金鑰」和「私密存取金鑰」,以供日後參考。
  12. 按一下「完成」。
  13. 選取 [權限] 分頁標籤。
  14. 在「權限政策」部分中,按一下「新增權限」。
  15. 選取「新增權限」。
  16. 選取「直接附加政策」。
  17. 搜尋 AmazonS3FullAccess 政策。
  18. 選取政策。
  19. 點選「下一步」。
  20. 按一下「Add permissions」。

建立虛擬私有雲流量記錄 (目的地:Amazon S3,格式:文字)

  1. 開啟 AWS 控制台 > VPC > 您的 VPC/子網路/網路介面,然後選取要記錄的範圍。
  2. 依序點選「動作」 > 「建立流量記錄」。
  3. 提供下列設定詳細資料:
    • 篩選:根據政策選擇「全部」 (或「接受」/「拒絕」)。
    • 最大匯總時間間隔:選取「1 分鐘」 (建議) 或「10 分鐘」。
    • 目的地:傳送至 Amazon S3 儲存貯體。
    • S3 bucket ARN:輸入上一節建立的 bucket 名稱,格式如下:arn:aws:s3:::<your-bucket>。
    • 記錄記錄格式:選取「AWS 預設格式」。
    • 記錄檔格式:選取「文字 (純文字)」。
    • 選用:除非必要,否則請停用「Hive-compatible prefixes」(與 Hive 相容的前置字元) 和「Hourly partitions」(每小時分區)。
  4. 按一下「建立流量記錄」。

在 Google SecOps 中設定資訊提供,擷取 AWS 虛擬私有雲流量記錄 (S3 文字)

  1. 依序前往「SIEM 設定」>「動態饋給」。
  2. 按一下「+ 新增動態消息」。
  3. 在「動態饋給名稱」欄位中輸入動態饋給名稱 (例如 AWS VPC Flow Logs - S3 (Text))。
  4. 選取「Amazon S3 V2」做為「來源類型」。
  5. 選取「AWS 虛擬私有雲流量記錄」做為「記錄類型」。
  6. 點選「下一步」。
  7. 指定下列輸入參數的值:
    • S3 URI:輸入 S3 bucket 位址 (例如 s3://<your-bucket>/AWSLogs/<account-id>/vpcflowlogs/<region>/)。
    • 來源刪除選項:根據偏好選取刪除選項。
    • 檔案存在時間上限:預設為 180 天。
    • 存取金鑰 ID:可存取 S3 bucket 的使用者存取金鑰。
    • 私密存取金鑰:具有 S3 bucket 存取權的使用者私密金鑰。
    • 資產命名空間:資產命名空間。
    • 擷取標籤:套用至這個動態饋給事件的標籤。
  8. 點選「下一步」。
  9. 在「Finalize」(完成) 畫面中檢查新的新聞動態消息設定,然後按一下「Submit」(提交)。

選項 2:使用 Amazon CloudWatch Logs 和 Kinesis Data Firehose 設定 AWS VPC 流量記錄匯出功能

設定將流量記錄傳送至 CloudWatch 後,這個選項會使用 Kinesis Data Firehose 將記錄資料串流至您選擇的目的地,提供額外的資料匯出層。

建立虛擬私有雲流量記錄 (目的地:Amazon CloudWatch Logs)

  1. 依序開啟「AWS Console」>「VPC」>「Your VPCs/Subnets/Network interfaces」。
  2. 依序點選「動作」>「建立流量記錄」。
  3. 提供下列設定詳細資料:
    • 篩選:根據政策選擇「全部」 (或「接受」/「拒絕」)。
    • 最大匯總時間間隔:選取「1 分鐘」 (建議) 或「10 分鐘」。
    • 目的地:選取「傳送至 CloudWatch Logs」。
    • 目的地記錄檔群組:選取或建立記錄檔群組 (例如 /aws/vpc/flowlogs)。
    • IAM 角色:選取可寫入 CloudWatch Logs 的角色。
    • 記錄格式:選取「AWS default」(AWS 預設) (第 2 版) 或「Custom」(自訂) (包含其他欄位)。
  4. 按一下「Create flow log」(建立流量記錄)。

在 Google SecOps 中建立動態饋給,取得端點網址和密鑰

  1. 依序前往「SIEM 設定」>「動態饋給」。
  2. 按一下「+ 新增動態消息」。
  3. 在「Feed name」(動態饋給名稱) 欄位中,輸入動態饋給名稱 (例如 AWS VPC Flow Logs - CloudWatch via Firehose)。
  4. 選取「Amazon Data Firehose」做為「來源類型」。
  5. 選取「AWS 虛擬私有雲流量記錄」做為「記錄類型」。
  6. 點選「下一步」。
  7. 指定下列輸入參數的值:
    • 分割分隔符號:選用 n。
    • 資產命名空間:資產命名空間 (例如 aws.vpc.flowlogs.cwl)。
    • 擷取標籤:要套用至這個動態饋給事件的標籤 (例如 source=vpc_flow_firehose)。
  8. 點選「下一步」。
  9. 檢查動態饋給設定,然後按一下「提交」。
  10. 按一下「產生密鑰」,產生用於驗證這個動態消息的密鑰。
  11. 複製並儲存密鑰,因為您無法再次查看這組密鑰。
  12. 前往「詳細資料」分頁。
  13. 從「端點資訊」欄位複製動態消息端點網址。
  14. 按一下「完成」。

為 Amazon Data Firehose 建立 API 金鑰

  1. 前往 Google Cloud 控制台的「憑證」頁面。
  2. 按一下「建立」憑證,然後選取「API 金鑰」。
  3. 複製金鑰並妥善儲存。
  4. 限制 Google SecOps API 的 API 金鑰存取權。

為 CloudWatch Logs 設定 Firehose 的 IAM 權限

  1. 在 AWS 控制台中,依序前往 「IAM」>「Policies」>「Create policy」>「JSON」。
  2. 貼上下列政策 JSON,並將 <region> 和 <account-id> 替換為您的 AWS 區域和帳戶 ID:

    {
    "Version": "2012-10-17",
    "Statement": [
       {
          "Effect": "Allow",
          "Action": [
          "firehose:PutRecord",
          "firehose:PutRecordBatch"
          ],
          "Resource": "arn:aws:firehose:<region>:<account-id>:deliverystream/cwlogs-to-secops"
       }
    ]
    }
    
  3. 為政策命名 CWLtoFirehoseWrite,然後點選「建立政策」。

  4. 依序前往「IAM」>「角色」>「建立角色」。

  5. 選取「Custom trust policy」,然後貼上:

    {
    "Version": "2012-10-17",
    "Statement": [
       {
          "Effect": "Allow",
          "Principal": {
          "Service": "logs.<region>.amazonaws.com"
          },
          "Action": "sts:AssumeRole"
       }
    ]
    }
    
  6. 將政策 CWLtoFirehoseWrite 附加至角色。

  7. 為角色命名 CWLtoFirehoseRole,然後按一下「建立角色」。

設定 Amazon Kinesis Data Firehose 至 Google SecOps

  1. 在 AWS 控制台中,依序前往「Kinesis」>「Data Firehose」>「Create delivery stream」。
  2. 請提供下列設定詳細資料:
    • 來源:選取「Direct PUT or other sources」。
    • 目的地:選擇「HTTP 端點」。
    • Name (名稱):cwlogs-to-secops
    • HTTP 端點網址:輸入 Google SecOps 的動態饋給 HTTPS 端點網址,並附加 API 金鑰:<ENDPOINT_URL>?key=<API_KEY>
    • HTTP 方法:選取「POST」。
  3. 在「Access key」(存取金鑰) 下方:
    • 輸入在 Google SecOps 動態饋給中產生的「密鑰」 (這會成為 X-Amz-Firehose-Access-Key 標頭)。
    • 緩衝區提示:將「緩衝區空間」設為 1 MiB,將「緩衝區間隔」設為 60 秒。
    • 壓縮:選取「停用」。
    • S3 backup:選取「Disabled」。
    • 將「重試」和「記錄」設定保留為「預設」。
  4. 按一下「建立放送串流」。

將 CloudWatch Logs 群組訂閱至 Firehose 串流

  1. 依序前往「CloudWatch」>「Logs」>「Log groups」。
  2. 選取目標記錄群組 (例如 /aws/vpc/flowlogs)。
  3. 開啟「訂閱篩選器」分頁,然後按一下「建立」。
  4. 選擇「建立 Amazon Kinesis Data Firehose 訂閱篩選器」。
  5. 提供下列設定詳細資料:
    • 目的地:選取放送串流 cwlogs-to-secops。
    • 授予權限:選擇角色 CWLtoFirehoseRole。
    • 篩選條件名稱:輸入 all-events。
    • 篩選器模式:留空即可傳送所有事件。
  6. 按一下「開始串流播放」。

選項 3:使用 Amazon S3 設定 CSV 格式的 AWS 虛擬私有雲流量記錄

將記錄轉換為 CSV 格式 (選用)

  1. 請確認 CSV 資料列遵循嚴格且一致的欄位順序,與您在虛擬私有雲流量記錄自訂格式中選取的欄位相符 (例如標準 v2 欄位集,或您的 v5/v7 集)。除非剖析器選項需要標頭列,否則請勿在製作檔案中加入標頭列。
  2. 將 CSV 檔案寫入穩定前置字元,例如:s3://<your-bucket>/vpcflowlogs-csv/<region>/year=<year>/month=<month>/day=<day>/。

在 Google SecOps 中設定資訊提供,以便擷取 AWS 虛擬私有雲流量記錄 (CSV)

  1. 依序前往 「SIEM 設定」 > 「動態饋給」。
  2. 按一下「+ 新增動態饋給」。
  3. 在「動態饋給名稱」欄位中輸入動態饋給名稱 (例如 AWS VPC Flow Logs - S3 (CSV))。
  4. 在「來源類型」部分,選取「Amazon S3 V2」。
  5. 「記錄類型」請選取「AWS 虛擬私有雲流量 (CSV)」。
  6. 點選「下一步」。
  7. 指定下列輸入參數的值:
    • S3 URI:輸入 S3 bucket 位址 (例如 s3://<your-bucket>/vpcflowlogs-csv/<region>/)。
    • 來源刪除選項:根據偏好選取刪除選項。
    • 檔案存在時間上限:預設為 180 天。
    • 存取金鑰 ID:可存取 S3 bucket 的使用者存取金鑰。
    • 私密存取金鑰:具有 S3 bucket 存取權的使用者私密金鑰。
    • 資產命名空間:資產命名空間。
    • 擷取標籤:套用至這個動態饋給事件的標籤。
  8. 點選「下一步」。
  9. 在「Finalize」(完成) 畫面中檢查新的動態饋給設定,然後按一下「Submit」(提交)。

UDM 對應表

記錄範例 記錄欄位 UDM 對應
"entries: { data: ""7,11111111111,eni-11aa1a1a1a1aa1a,1.1.1.1,2.2.2.2,51256,16020,6,14,3881,1723542839,1723542871,ACCEPT,OK,vpc-1aa1a1a1a1aa1aa,subnet-1aa1a1a1a1aa1a1,i-1aa1a1a1a1aa1a,0,IPv4,1.1.1.1,2.2.2.2,ap-northeast-1,masked_zone,-,-,-,-,ingress,,-,-,-,-,-,-,-,-,-,-"" collection_time: { seconds: 1741159282 nanos: 254633949 } }" 7 metadata.product_version
11111111111 metadata.product_log_id
eni-11aa1a1a1a1aa1a principal.user.product_object_id
1.1.1.1 principal.ip
2.2.2.2 target.ip
51256 principal.port
16020 target.port
6 network.ip_protocol
14 network.sent_packets
3881 network.received_bytes
1723542839 metadata.event_timestamp about.resource.attribute.labels(start_time)
1723542871 metadata.ingested_timestamp about.resource.attribute.labels(end_time)
ACCEPT security_result.action security_result.action_details
OK about.resource.attribute.labels (log-status)
vpc-1aa1a1a1a1aa1a principal.resource.attribute.labels (vpcID)
subnet-a1a1a1a1a1 principal.asset_id
i-1aa1a1a1a1aa1a principal.resource_ancestors.product_object_id
0 about.resource.attribute.labels (type)
IPv4 additional.fields (pkt-srcaddr-ip)
1.1.1.1 intermediary.ip
2.2.2.2 additional.fields (tcp_flags)
ap-northeast-1 not getting mapped
masked_zone not getting mapped
- about.resource.attribute.labels (sublocation_type)
- about.resource.attribute.labels (sublocation_id)
- about.resource.attribute.labels (pkt_src_aws_service)
- about.resource.attribute.labels (pkt_dst_aws_service)
ingress network.direction
additional.fields (traffic_path)
- not getting mapped
- not getting mapped-
"entries: { data: ""7,11111111111,eni-11aa1a1a1a1aa1a,5.5.5.5,2.2.2.2,53102,16020,6,8,2112,1723542839,1723542871,ACCEPT,OK,vpc-1aa1a1a1a1aa1a,subnet-1aa1a1a1a1aa1a,i-1aa1a1a1a1aa1a,0,IPv4,5.5.5.5,2.2.2.2,ap-northeast-1,masked_zone,-,-,-,-,ingress,,-,-,-,-,-,-,-,-,-,-"" collection_time: { seconds: 1741159390 nanos: 374934225 } }" 7 metadata.product_version
11111111111 metadata.product_log_id
eni-11aa1a1a1a1aa1a principal.user.product_object_id
5.5.5.5 principal.ip
2.2.2.2 target.ip
53102 principal.port
16020 target.port
6 network.ip_protocol
8 network.sent_packets
2112 network.received_bytes
1723542839 metadata.event_timestamp about.resource.attribute.labels(start_time)
1723542871 metadata.ingested_timestamp about.resource.attribute.labels(end_time)
ACCEPT security_result.action security_result.action_details
OK about.resource.attribute.labels (log-status)
vpc-1aa1a1a1a1aa1a principal.resource.attribute.labels (vpcID)
subnet-1aa1a1a1a1aa1a principal.asset_id
i-1aa1a1a1a1aa1a principal.resource_ancestors.product_object_id
0 about.resource.attribute.labels (type)
IPv4 additional.fields (pkt-srcaddr-ip)
5.5.5.5 intermediary.ip
2.2.2.2 additional.fields (tcp_flags)
ap-northeast-1 not getting mapped
masked_zone not getting mapped
- about.resource.attribute.labels (sublocation_type)
- about.resource.attribute.labels (sublocation_id)
- about.resource.attribute.labels (pkt_src_aws_service)
- about.resource.attribute.labels (pkt_dst_aws_service)
ingress network.direction
additional.fields (traffic_path)
- not getting mapped
- not getting mapped1
"entries: { data: ""7,11111111111,eni-11aa1a1a1a1aa1a,1.1.2.2,1.1.2.1,36358,42659,6,1091,3.754327e+06,1747981553,1747981582,ACCEPT,OK,vpc-1aa1a1a1a1aa1a,subnet-1aa1a1a1a1aa1a,i-1aa1a1a1a1aa1a,0,IPv4,1.1.2.2,1.1.2.1,ap-northeast-1,apne1-az1,-,-,-,-,egress,1,-,-,-,-,-,-,-,-,-,-,604249"" collection_time: { seconds: 1748238552 nanos: 479960397 } }" 7 metadata.product_version
11111111111 metadata.product_log_id
eni-11aa1a1a1a1aa1a about.resource.attribute.labels
1.1.2.2 principal.ip
1.1.2.1 target.ip
36358 principal.port
42659 target.port
6 network.ip_protocol
1091 network.sent_packets
3.75E+06 network.sent_bytes
1747981553 metadata.event_timestamp about.resource.attribute.labels(start_time)
1747981582 metadata.ingested_timestamp about.resource.attribute.labels(end_time)
ACCEPT security_result.action security_result.action_details
OK about.resource.attribute.labels (log-status)
vpc-1aa1a1a1a1aa1a principal.resource.attribute.labels (vpcID)
subnet-1aa1a1a1a1aa1a principal.asset_id
i-1aa1a1a1a1aa1a principal.resource_ancestors.product_object_id
0 additional.fields (tcp_flags)
IPv4 about.resource.attribute.labels(type)
1.1.2.2 "additional.fields (pkt-srcaddr-ip)
條件:
if [pkt_dstaddr_ip] != [dstaddr] will map to intermediary.ip"
1.1.2.1 "additional.fields (pkt-dstaddr-ip)
條件:
if [pkt_srcaddr_ip] != [srcaddr] will map to intermediary.ip"
ap-northeast-1 principal.location.country_or_region
apne1-az1 principal.location.name
- about.resource.attribute.labels (sublocation_type)
- about.resource.attribute.labels (sublocation_id)
- about.resource.attribute.labels (pkt_src_aws_service)
- about.resource.attribute.labels (pkt_dst_aws_service)
egress network.direction
1 additional.fields (traffic_path)
- not getting mapped
604249 not getting mapped
Connection_info.Tcp_flags additional.fields
connection_info.tcp_flags additional.fields
Dst_endpoint.Interface_uid target.user.product_object_id
Log_status additional.fields
Src_endpoint.Instance_uid principal.user.product_object_id
Tcp_flags additional.fields
tcp_flags additional.fields
tgw_dst_az_id target.resource.attribute.cloud.availability_zone
tgw_id target.resource.product_object_id
tgw_src_az_id principal.location.name
Traffic_Bytes network.sent_bytes
Traffic_Packets network.sent_packets

版本差異

Google SecOps 已發布 AWS 虛擬私有雲流量記錄剖析器 16.0 版,其中大幅變更 Parser_Name 記錄欄位與 UDM 欄位的對應關係,以及事件類型的對應關係。

記錄欄位對應差異

記錄欄位 舊對應 目前對應
bytes network.sent_bytes Removed
Connection_info.Tcp_flags network.dhcp.flags additional.fields
connection_info.tcp_flags network.dhcp.flags additional.fields
Dst_endpoint.Interface_uid additional.fields target.user.product_object_id
flow_direction about.resource.attribute.labels Removed
Log_status about.resource.attribute.labels additional.fields
Src_endpoint.Instance_uid additional.fields principal.user.product_object_id
Tcp_flags network.dhcp.flags additional.fields
tcp_flags network.dhcp.flags additional.fields
tgw_dst_az_id target.resource.attribute.labels target.resource.attribute.cloud.availability_zone
tgw_id additional.fields target.resource.product_object_id
tgw_src_az_id principal.resource.attribute.labels principal.location.name
Traffic_Bytes additional.fields network.sent_bytes
Traffic_Packets additional.fields network.sent_packets

事件類型對應差異

系統現在會以有意義的事件類型,正確分類先前以一般方式分類的多個事件。

事件類型 記錄檔中的欄位 原因
FILE_UNCATEGORIZED Bytes 這個 PR 中新處理的事件會對應至適當的特定事件類型
NETWORK_CONNECTION protocol 這個 PR 中新處理的事件會對應至適當的特定事件類型
NETWORK_UNCATEGORIZED Class_name 這個 PR 中新處理的事件會對應至適當的特定事件類型
NETWORK_UNCATEGORIZED flow_direction 這項 PR 會以新的方式處理,對應至適當的特定事件類型
STATUS_UPDATE [src_endpoint][ip] 這項 PR 會以新的方式處理,對應至適當的特定事件類型

變更記錄

查看這個剖析器的變更記錄

還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求解答。