收集 AWS VPC 流量記錄

剖析器版本:17.0

支援的服務:

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

支援的 AWS VPC 流量記錄格式

Google SecOps 支援擷取兩種主要文字格式的 AWS VPC 流量記錄:

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

由於 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 和 IAM 權限,以便匯出虛擬私有雲流量記錄,供 Google SecOps 分析。

為 Google SecOps 設定 AWS S3 bucket 和 IAM

  1. 按照這份使用手冊建立 bucket,建立 Amazon S3 bucket。
  2. 儲存 bucket 的「名稱」和「區域」,以供日後參考 (例如 aws-vpc-flowlogs)。
  3. 按照這份使用手冊建立 IAM 使用者,建立使用者。
  4. 選取建立的使用者。
  5. 選取「Security credentials」(安全憑證) 分頁標籤。
  6. 在「Access Keys」部分,按一下「Create Access Key」。
  7. 在「用途」部分選取「第三方服務」。
  8. 點選「下一步」。
  9. 選用:新增說明標記。
  10. 按一下「Create access key」。
  11. 按一下「Download CSV file」,儲存「Access Key」和「Secret Access Key」,以供日後參考。
  12. 按一下「完成」。
  13. 選取 [權限] 分頁標籤。
  14. 在「權限政策」部分,按一下「新增權限」。
  15. 選取「新增權限」。
  16. 選取「Attach policies directly」。
  17. 搜尋 AmazonS3FullAccess 政策。
  18. 選取政策。
  19. 點選「下一步」。
  20. 按一下「Add permissions」。

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

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

在 Google SecOps 設定動態饋給,擷取 AWS VPC 流量記錄 (S3 文字)

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

選項 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. 提供下列設定詳細資料:
    • 篩選器:根據政策選擇「全部」(或「接受」/「拒絕」)。
    • 「Maximum aggregation interval」(匯總時間間隔上限):選取「1 minute」(1 分鐘) (建議) 或「10 minutes」(10 分鐘)。
    • Destination:選取「Send to CloudWatch Logs」。
    • 目的地記錄群組:選取或建立記錄群組 (例如 /aws/vpc/flowlogs)。
    • IAM 角色:選取可寫入 CloudWatch Logs 的角色。
    • 記錄格式:選取「AWS default」(AWS 預設) (第 2 版) 或「Custom」(自訂) (包含其他欄位)。
  4. 按一下「Create flow log」(建立流量記錄)。

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

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

為 Amazon Data Firehose 動態饋給建立 API 金鑰

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

設定 IAM 權限,將 CloudWatch 記錄傳送至 Firehose

  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」(直接 PUT 或其他來源)。
    • 目的地:選擇「HTTP endpoint」(HTTP 端點)。
    • Name (名稱):cwlogs-to-secops
    • HTTP 端點網址:輸入 Google SecOps 的動態饋給 HTTPS 端點網址,並附加 API 金鑰:<ENDPOINT_URL>?key=<API_KEY>
    • HTTP 方法:選取「POST」。
  3. 在「存取金鑰」下方:
    • 輸入 Google SecOps 動態饋給中產生的密鑰 (這會成為 X-Amz-Firehose-Access-Key 標頭)。
    • 緩衝提示:將「緩衝區空間」設為 1 MiB,「緩衝時間間隔」設為 60 秒。
    • 壓縮:選取「停用」。
    • S3 backup:選取「Disabled」。
    • 將「retry」和「logging」設定保留為「default」。
  4. 按一下「Create delivery stream」(建立傳遞串流)。

將 CloudWatch Logs 群組訂閱至 Firehose 串流

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

選項 3:使用 Amazon S3 設定 CSV 格式的 AWS VPC 流量記錄

將記錄轉換為 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. 在「Feed name」(動態饋給名稱) 欄位中,輸入動態饋給名稱 (例如 AWS VPC Flow Logs - S3 (CSV))。
  4. 在「來源類型」部分,選取「Amazon S3 V2」。
  5. 「記錄類型」請選取「AWS VPC Flow (CSV)」。
  6. 點選「下一步」。
  7. 指定下列輸入參數的值:
    • S3 URI:輸入 S3 bucket 位址 (例如 s3://<your-bucket>/vpcflowlogs-csv/<region>/)。
    • 來源刪除選項:根據偏好選取刪除選項。
    • 檔案存在時間上限:預設為 180 天。
    • 存取金鑰 ID:可存取 S3 bucket 的使用者存取金鑰。
    • Secret Access Key:可存取 S3 bucket 的使用者私密金鑰。
    • Asset namespace:資產命名空間。
    • 擷取標籤:套用至這個動態饋給事件的標籤。
  8. 點選「下一步」。
  9. 在「完成」畫面中檢查新的新聞動態消息設定,然後按一下「提交」。

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 專業人員尋求解答。