手動管理轉送站設定

支援的服務:

本頁面說明如何手動建立及修改 Google Security Operations 轉寄站設定檔。如要透過使用者介面設定轉寄站 (建議做法),請參閱「透過 Google SecOps 使用者介面管理轉寄站設定」。

每個部署的 Google SecOps 轉寄站都需要轉寄站設定檔。轉寄站設定檔會指定將資料移轉至 Google SecOps 執行個體的設定。

如要瞭解如何安裝及設定 Google SecOps 轉寄站、系統需求,以及設定詳細資料,請參閱「安裝及設定轉寄站」。

事前準備

建立設定檔前,請先規劃導入方式,瞭解可擷取的資料類型,以及需要在設定檔中定義的重要屬性。

建立設定檔

如要手動建立設定檔,請按照下列步驟操作:

  1. 透過 UI 下載設定檔。

  2. 使用下列命名慣例,將這兩個檔案儲存在同一個目錄中:

    FORWARDER_NAME.conf:使用這個檔案定義與記錄擷取相關的設定。

    FORWARDER_NAME_auth.conf:使用這個檔案定義授權憑證。

  3. 修改檔案,加入轉寄站執行個體的設定。

    如要進一步瞭解各類擷取機制 (例如 Splunk 或 Syslog) 的設定,請參閱「在設定檔中定義資料類型」。如要進一步瞭解如何自訂各項屬性 (例如資料壓縮或磁碟緩衝),請參閱「在設定檔中設定重要屬性」。

  4. 請確認 FORWARDER_NAME_auth.conf 設定檔中每個輸入內容都有對應的項目,即使輸入內容沒有對應的驗證詳細資料也一樣。必須提供這項資訊,才能正確對應資料。

轉寄站會在五分鐘內自動套用對設定檔所做的任何變更。

設定範例

您可以參考下列設定檔,做為建立自己的範本。

雙檔案設定範例

這個雙檔案系統會將驗證憑證儲存在獨立檔案中,提高安全性。您可以將 FORWARDER_NAME.conf 檔案儲存在版本管控存放區或任何開放式設定管理系統中。您可以將 FORWARDER_NAME_auth.conf 設定檔直接儲存在執行轉送器的實體或虛擬機器中。

下列程式碼範例顯示轉送站設定檔的格式。

FORWARDER_NAME.conf 檔案

output:
  url: {region}-chronicle.googleapis.com (for example: us-chronicle.googleapis.com)
  use_dataplane : true
  project_id: PROJECT_ID
  region: {region} (for example: {us})
  identity:
    identity:
    collector_id: COLLECTOR_ID \
    customer_id: CUSTOMER_ID \

collectors:
  - syslog:
      common:
        enabled: true
        data_type: "WINDOWS_DHCP"
        data_hint:
        batch_n_seconds: 10
        batch_n_bytes: 1048576
      tcp_address: 0.0.0.0:10514
      udp_address: 0.0.0.0:10514
      connection_timeout_sec: 60
      tcp_buffer_size: 524288
  - syslog:
      common:
        enabled: true
        data_type: "WINDOWS_DNS"
        data_hint:
        batch_n_seconds: 10
        batch_n_bytes: 1048576
      tcp_address: 0.0.0.0:10515
      connection_timeout_sec: 60
      tcp_buffer_size: 524288

FORWARDER_NAME_auth.conf 檔案

output:
  identity:
    secret_key: |
      {
        "type": "service_account",
        "project_id": "PROJECT_ID" \,
        "private_key_id": "PRIVATE_KEY_ID" \,
        "private_key": "-----BEGIN PRIVATE KEY-----\\"PRIVATE_KEY" \n-----END PRIVATE KEY-----\n",
        "client_email": "CLIENT_EMAIL" \,
        "client_id": "CLIENT_ID" \,
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/example-account-1%40example-account.iam.gserviceaccount.com"
      }

collectors:
  - syslog:
  - syslog:
      certificate: "../forwarder/inputs/testdata/localhost.pem"
      certificate_key: "../forwarder/inputs/testdata/localhost.key"

單一檔案設定範例

output:
  url: us-chronicle.googleapis.com
  use_dataplane: true
  project_id: PROJECT_ID
  region: us
    identity:
    collector_id: COLLECTOR_ID \
    customer_id: CUSTOMER_ID \
    secret_key: |
      {
        "type": "service_account",
        "project_id": "PROJECT_ID" \,
        "private_key_id": "PRIVATE_KEY_ID" \,
        "private_key": "-----BEGIN PRIVATE KEY-----\ "PRIVATE_KEY" \n-----END PRIVATE KEY-----\n",
        "client_email": "CLIENT_EMAIL" \,
        "client_id": "CLIENT_ID" \,
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/malachite-test-1%40malachite-test.iam.gserviceaccount.com"
      }

collectors:
  - syslog:
      common:
        enabled: true
        data_type: "WINDOWS_DHCP"
        data_hint:
        batch_n_seconds: 10
        batch_n_bytes: 1048576
      tcp_address: 0.0.0.0:10514
      udp_address: 0.0.0.0:10514
      connection_timeout_sec: 60
      tcp_buffer_size: 524288
  - syslog:
      common:
        enabled: true
        data_type: "WINDOWS_DNS"
        data_hint:
        batch_n_seconds: 10
        batch_n_bytes: 1048576
      tcp_address: 0.0.0.0:10515
      connection_timeout_sec: 60
      certificate: "../forwarder/inputs/testdata/localhost.pem"
      certificate_key: "../forwarder/inputs/testdata/localhost.key"
      tcp_buffer_size: 524288

從單一檔案轉換為兩個檔案系統

如果您使用的是單一設定檔,並想改用雙檔案系統,請按照下列步驟操作:

  1. 複製現有設定檔。

  2. 將其中一個檔案儲存為 FORWARDER_NAME.conf 設定檔,並刪除檔案中的授權憑證。

  3. 將另一個檔案儲存為 FORWARDER_NAME_auth.conf 設定檔,並刪除檔案中所有非授權資料。您可以參考設定範例。請務必遵循「自訂設定」一節中提及的命名慣例和其他規範。

在設定檔中定義資料類型

下列各節將說明如何設定 Google SecOps 轉寄站,擷取不同類型的資料,並轉寄至 Google SecOps 執行個體。

Splunk 資料

您可以設定 Google SecOps 轉寄站,將 Splunk 資料轉寄至 Google SecOps。Google Cloud 使用下列資訊設定 Google SecOps 轉寄站,從 Splunk 轉寄資料:

  • Splunk REST API 的網址 (例如 https://10.0.113.15:8089)。

  • Splunk 查詢,用於為每種必要資料類型產生資料 (例如 index=dns)。

FORWARDER_NAME.conf
output:
collectors:
  - splunk:
      common:
        enabled: true
        data_type: WINDOWS_DNS
        data_hint: "#fields ts      uid     id.orig_h       id.orig_p       id.resp_h         id.resp_p       proto   trans_id        query   qclass  qclass_name"
        batch_n_seconds: 10
        batch_n_bytes: 819200
      url: https://127.0.0.1:8089
      is_ignore_cert: true
      minimum_window_size: 10s
      maximum_window_size: 30s
      query_string: search index=* sourcetype=dns
      query_mode: realtime
  • 將 Splunk 帳戶憑證提供給 Google SecOps 轉寄站。方法是建立 creds.txt 檔案。

如要使用 creds.txt 檔案,請按照下列步驟操作:

  1. 為 Splunk 憑證建立本機檔案,並命名為 creds.txt。

  2. 在第一行輸入使用者名稱,第二行輸入密碼:

    cat creds.txt
    
    myusername
    mypassword
    
  3. 如要使用 Google SecOps 轉寄站存取 Splunk 執行個體,請將 creds.txt 檔案複製到設定目錄 (設定檔所在的目錄)。

    Linux

    cp creds.txt /opt/chronicle/config/creds.txt
    

    Windows

    cp creds.txt c:/opt/chronicle/config/creds.txt
    
  4. 確認 creds.txt 檔案位於預期目錄中:

    Linux

      ls /opt/chronicle/config
    

    Windows

    ls c:/opt/chronicle/config
    

Syslog 資料

轉寄站可做為 Syslog 伺服器。只要伺服器支援透過 TCP 或 UDP 連線傳送 Syslog 資料,您就能設定將資料轉送至 Google SecOps 轉寄站。您可以控制伺服器傳送至轉送器的資料,轉送器再將資料轉送至 Google SecOps。

FORWARDER_NAME.conf 設定檔 (由Google Cloud提供) 會指定要監控每種轉送資料類型的哪些通訊埠 (例如通訊埠 10514)。根據預設,Google SecOps 轉寄站會接受 TCP 和 UDP 連線。

您可以自訂 TCP 緩衝區空間。預設 TCP 緩衝區空間為 64 KB。connection_timeout 的預設值和建議值為 60 秒。如果連線閒置超過 60 秒,TCP 連線就會終止。

設定 rsyslog

如要設定 rsyslog,您必須為每個通訊埠 (例如每個資料類型) 指定目標。以下範例說明 rsyslog 目標設定:

  • TCP 記錄流量:dns.* @@192.168.0.12:10514

  • UDP 記錄流量:dns.* @192.168.0.12:10514

詳情請參閱系統說明文件。

為 Syslog 設定啟用 TLS

您可以為 Syslog 連線啟用 TLS,連至 Google SecOps 轉寄站。在轉寄站設定檔 (FORWARDER_NAME.conf) 中,指定自行產生的憑證和憑證金鑰位置,如以下範例所示。您可以在 configuration 目錄下建立 certs 目錄,並將憑證檔案儲存在其中。

Linux:

憑證 /opt/chronicle/external/certs/client_generated_cert.pem
certificate_key /opt/chronicle/external/certs/client_generated_cert.key

Windows:

憑證 c:/opt/chronicle/external/certs/client_generated_cert.pem
certificate_key c:/opt/chronicle/external/certs/client_generated_cert.key

根據範例,修改轉寄站設定檔 (FORWARDER_NAME.conf),如下所示:

Linux:

 collectors:
- syslog:
   common:
     enabled: true
     data_type: WINDOWS_DNS
     data_hint:
     batch_n_seconds: 10
     batch_n_bytes: 1048576
   tcp_address: 0.0.0.0:10515
   tcp_buffer_size: 65536
   connection_timeout_sec: 60
   certificate: "/opt/chronicle/external/certs/client_generated_cert.pem"
   certificate_key: "/opt/chronicle/external/certs/client_generated_cert.key"
   minimum_tls_version: "TLSv1_3"

Windows:

  collectors:
- syslog:
    common:
      enabled: true
      data_type: WINDOWS_DNS
      data_hint:
      batch_n_seconds: 10
      batch_n_bytes: 1048576
    tcp_address: 0.0.0.0:10515
    tcp_buffer_size: 65536
    connection_timeout_sec: 60
    certificate: "c:/opt/chronicle/external/certs/client_generated_cert.pem"
    certificate_key: "c:/opt/chronicle/external/certs/client_generated_cert.key"
    minimum_tls_version: "TLSv1_3"

輸入要求的 TLS 版本應高於最低 TLS 版本。最低 TLS 版本應為下列其中一個值:TLSv1_0、TLSv1_1、TLSv1_2、TLSv1_3。

檔案資料

檔案收集器旨在從繫結至 Docker 容器的檔案擷取記錄。如要手動上傳單一記錄檔中的記錄,可以使用這個選項。

從 Docker 容器啟動 Google SecOps 轉寄站,將負載磁碟區對應至容器:

Linux

     docker run 
--detach
--name cfps
--log-opt max-size=100m
--log-opt max-file=10
--net=host
-v /opt/chronicle/config:/opt/chronicle/external
-v /var/log/crowdstrike/falconhostclient:/opt/chronicle/edr
gcr.io/chronicle-container/cf_production_stable

Windows

  docker run `
    --name cfps `
    --log-opt max-size=100m `
    --log-opt max-file=10 `
    -p 10514:10514 `
    -v c:/opt/chronicle/config:c:/opt/chronicle/external `
    -v c:/var/log/crowdstrike/falconhostclient:c:/opt/chronicle/edr `
     gcr.io/chronicle-container/cf_production_stable_windows

您可以使用多個選項或多個範圍,新增多個通訊埠。例如:-p 3001:3000 -p 2023:2022 或 -p 7000-8000:7000-8000。程式碼範例中的通訊埠編號僅供參考。請視需求更換通訊埠編號。

您可以根據範例,修改 Google SecOps 轉寄站設定 (FORWARDER_NAME.conf 檔案),如下所示:

Linux

collectors:
 - file:
      common:
        enabled: true
        data_type: CS_EDR
        data_hint:
        batch_n_seconds: 10
        batch_n_bytes: 1048576
      file_path: /opt/chronicle/edr/sample.txt
      filter:

Windows

 collectors:
  - file:
       common:
         enabled: true
         data_type: CS_EDR
         data_hint:
         batch_n_seconds: 10
         batch_n_bytes: 1048576
       file_path: c:/opt/chronicle/edr/sample.txt
       filter:

sample.txt 檔案應位於 /var/log/crowdstrike/falconhostclient 資料夾中。

旗標設定

skip_seek_to_end (bool):這個旗標預設為 false,檔案輸入只會傳送新的記錄行做為輸入。如果將這個值設為 true,轉送站重新啟動時,系統會再次傳送所有先前的記錄行。這會導致記錄重複。在某些情況下 (例如服務中斷期間),將這個旗標設為 true 很有幫助,因為重新啟動轉送工具會再次傳送缺少的記錄行。

poll (bool):檔案收集器會使用 Tail 程式庫,檢查檔案系統是否有任何變更。將這個旗標設為 true,Tail 程式庫就會使用輪詢方法,而非預設的通知方法。

封包資料

Google SecOps 轉送站可以直接從網路介面擷取封包,而非記錄項目。

Linux 系統

Google SecOps 轉寄站可在 Linux 上使用 libcap 擷取封包。如要進一步瞭解 libcap,請參閱 libcap - Linux 手冊頁面。

系統會擷取原始網路封包並傳送至 Google SecOps,而非記錄項目。這項擷取作業僅限於本機介面。如要為系統啟用封包擷取功能,請與 Google SecOps 支援團隊聯絡。

Google SecOps 會使用擷取封包時使用的 Berkeley 封包篩選器 (BPF) 運算式 (例如通訊埠 53,而非 localhost),設定 Google SecOps 轉寄站。詳情請參閱「Berkeley 封包篩選器」。

Windows 系統

Google SecOps 轉寄站可使用 Windows 系統上的 Npcap 擷取封包。

系統會擷取原始網路封包並傳送至 Google SecOps,而非記錄項目。這項擷取作業僅限於本機介面。如要設定 Google SecOps 轉寄站來擷取封包,請與 Google SecOps 支援團隊聯絡。

封包擷取 PCAP 轉寄站的需求條件:

  • 在 Microsoft Windows 主機上安裝 Npcap。

  • 授予 Google SecOps 轉寄站根權限或管理員權限,以便監控網路介面。

  • 在 Npcap 安裝過程中,啟用 WinPcap 相容模式。

如要設定 PCAP 轉送器, Google Cloud 需要用於擷取封包的介面 GUID。在要安裝 Google SecOps 轉寄站的機器 (伺服器或監聽 span 連接埠的機器) 上執行 getmac.exe,並將輸出內容傳送至 Google SecOps。

或者,您也可以修改設定檔。找出 PCAP 區段,並將現有的 GUID 值替換為執行 getmac.exe 取得的 GUID。

例如,以下是原始 PCAP 區段:

- pcap:
      common:
        enabled: true
        data_type: PCAP_DNS
        batch_n_seconds: 10
        batch_n_bytes: 1048576
      interface: \Device\NPF_{1A7E7C8B-DD7B-4E13-9637-0437AB1A12FE}
      bpf: udp port 53

執行 getmac.exe 的輸出內容:

C:\>getmac.exe
  Physical Address    Transport Name
  ===========================================================================
  A4-73-9F-ED-E1-82   \Device\Tcpip_{2E0E9440-ABFF-4E5B-B43C-E188FCAD1234}

修訂後的 PCAP 部分,包含新的 GUID:

- pcap:
      common:
        enabled: true
        data_type: PCAP_DNS
        batch_n_seconds: 10
        batch_n_bytes: 1048576
      interface: \Device\NPF_{2E0E9440-ABFF-4E5B-B43C-E188FCAD9734}
      bpf: udp port 53

傳輸名稱的 getmac.exe 輸出內容開頭為 \Device\Tcpip,而可比較的 pcap 區段開頭為 \Device\NPF。

Kafka 主題中的資料

Google SecOps 轉送站支援直接從 Kafka 主題擷取資料。您最多可以部署三個轉送站,並利用消費者群組的概念,從同一個 Kafka 主題提取資料,進行高效率的平行處理。詳情請參閱 Kafka。如要進一步瞭解 Kafka 消費者群組,請參閱「Kafka 消費者」。

下列轉寄站設定說明如何設定轉寄站,從 Kafka 主題擷取資料。

Linux

FORWARDER_NAME.conf 檔案

   collectors:
   - kafka:
         common:
           batch_n_bytes: 1048576
           batch_n_seconds: 10
           data_hint: null
           data_type: NIX_SYSTEM
           enabled: true
         topic: example-topic
         group_id: chronicle-forwarder
         timeout: 60s
         brokers: ["broker-1:9092", "broker-2:9093"]
         tls:
           insecureSkipVerify: true
           certificate: "/path/to/cert.pem"
           certificate_key: "/path/to/cert.key"
   - syslog:
         common:
           batch_n_bytes: 1048576
           batch_n_seconds: 10
           data_hint: null
           data_type: WINEVTLOG
           enabled: true
         tcp_address: 0.0.0.0:30001
         connection_timeout_sec: 60
   

FORWARDER_NAME_auth.conf 檔案

   collectors:
   - kafka:
         username: user
         password: password
   - syslog:
   

Windows

FORWARDER_NAME.conf 設定檔

collectors:
- kafka:
      common:
        batch_n_bytes: 1048576
        batch_n_seconds: 10
        data_hint: null
        data_type: NIX_SYSTEM
        enabled: true
      topic: example-topic
      group_id: chronicle-forwarder
      timeout: 60s
      brokers: ["broker-1:9092", "broker-2:9093"]
      tls:
        insecureSkipVerify: true
        certificate: "c:/path/to/cert.pem"
        certificate_key: "c:/path/to/cert.key"
- syslog:
      common:
        batch_n_bytes: 1048576
        batch_n_seconds: 10
        data_hint: null
        data_type: WINEVTLOG
        enabled: true
      tcp_address: 0.0.0.0:30001
      connection_timeout_sec: 60

FORWARDER_NAME_auth.conf 檔案

collectors:
- kafka:
      username: user
      password: password
- syslog:

WebProxy 資料

Google SecOps 轉寄站可以直接從網路介面擷取 WebProxy 資料。

Linux

Google SecOps 轉寄站可使用 Linux 上的 libcap 擷取 WebProxy 資料。如要進一步瞭解 libcap,請參閱 libcap - Linux 手冊頁面。如要為系統啟用 WebProxy 資料擷取功能,請與 Google SecOps 支援團隊聯絡。

按照下列方式修改 Google SecOps 轉送站設定 (FORWARDER_NAME.conf 檔案):

   - webproxy:
         common:
           enabled : true
           data_type: <Your LogType>
           batch_n_seconds: 10
           batch_n_bytes: 1048576
         interface: any
         bpf: tcp and dst port 80

Windows

轉送站可使用 Npcap 擷取 WebProxy 資料,並傳送至 Google Cloud。

如要為系統啟用 WebProxy 資料擷取功能,請與 Google SecOps 支援團隊聯絡。

執行 WebProxy 轉送工具前,請先完成下列步驟:

  1. 在 Microsoft Windows 主機上安裝 Npcap。在安裝期間啟用 WinPcap 相容模式。

  2. 將根或管理員權限授予轉送站,以監控網路介面。

  3. 取得用於擷取 WebProxy 封包的介面 GUID。

    在要安裝 Google SecOps 轉寄站的機器上執行 getmac.exe,並將輸出內容傳送至 Google SecOps。或者,您也可以修改設定檔。找出 WebProxy 區段,將介面旁顯示的 GUID 替換為執行 getmac.exe 後顯示的 GUID。

    按照下列方式修改 Google SecOps 轉送站設定檔 (FORWARDER_NAME.conf):

      - webproxy:
        common:
            enabled : true
            data_type: <Your LogType>
            batch_n_seconds: 10
            batch_n_bytes: 1048576
          interface: \Device\NPF_{2E0E9440-ABFF-4E5B-B43C-E188FCAD9734}
          bpf: tcp and dst port 80
    

在設定檔中設定重要屬性

下表列出轉寄站設定檔中使用的重要參數。

參數 說明
data_type 收集器可收集及處理的記錄資料類型。
中繼資料 中繼資料,會覆寫全域中繼資料。
max_file_buffer_bytes 磁碟或檔案緩衝區可累積的位元組數上限。預設值為 1073741824,也就是 1 GB。
max_memory_buffer_bytes 記憶體緩衝區可累積的位元組數上限。預設值為 1073741824,也就是 1 GB。
write_to_disk_dir_path 檔案或磁碟緩衝區使用的路徑。
write_to_disk_buffer_enabled 如果為 true,系統會使用磁碟緩衝區,而非記憶體緩衝區。預設值為 false。
batch_n_bytes 收集器可累積的位元組數上限,超過這個上限後,資料就會分批處理。預設值為 1048576,也就是 1 MB。
batch_n_seconds 收集器收集的資料會在幾秒後批次處理。預設值為 11 秒。
data_hint 收集器可接收的資料格式 (通常是說明格式的記錄檔標頭)。

如需設定檔中使用的參數完整清單,請參閱「轉寄站設定欄位」和「收集器設定欄位」。

資料壓縮

記錄壓縮功能預設為停用。啟用記錄壓縮功能可能會減少頻寬消耗。不過,啟用記錄壓縮功能也可能會增加 CPU 使用率。請根據環境和記錄資料,評估如何取捨。

如要啟用記錄壓縮功能,請在 Google SecOps 轉寄站設定檔中,將 compression 欄位設為 true,如以下範例所示:

FORWARDER_NAME.conf 檔案

output:
  compression: true
    url: malachiteingestion-pa.googleapis.com:443
    identity:
      identity:
      collector_id: 10479925-878c-11e7-9421-10604b7cb5c1
      customer_id: ebdc4bb9-878b-11e7-8455-10604b7cb5c1
...

FORWARDER_NAME_auth.conf 檔案

output:
  identity:
    secret_key: |
    {
     "type": "service_account",
...
    }

磁碟緩衝

磁碟緩衝功能可讓您將待處理的訊息暫存至磁碟,而非記憶體。

您可以設定自動記憶體緩衝,在收集器之間使用動態共用緩衝區,更妥善地處理流量高峰。如要啟用動態共用緩衝區,請在轉送站設定中加入下列內容:

auto_buffer:
  enabled: true
  target_memory_utilization: 80

如果啟用自動磁碟緩衝,但未定義 target_memory_utilization,則會使用預設值 70。

如果您使用 Docker 執行轉寄站,建議您從設定磁碟區掛接獨立磁碟區,以便隔離。此外,每個輸入內容都應使用專屬目錄或磁碟區隔離,以免發生衝突。

範例設定

下列設定包含啟用磁碟緩衝的語法:

collectors:
- syslog:
    common:
      write_to_disk_buffer_enabled: true
      # /buffers/NIX_SYSTEM is part of the external mounted volume for the
forwarder
      write_to_disk_dir_path: /buffers/NIX_SYSTEM
      max_file_buffer_bytes: 1073741824
      batch_n_bytes: 1048576
      batch_n_seconds: 10
      data_hint: null
      data_type: NIX_SYSTEM
      enabled: true
    tcp_address: 0.0.0.0:30000
    connection_timeout_sec: 60
- syslog:
    common:
      batch_n_bytes: 1048576
      batch_n_seconds: 10
      data_hint: null
      data_type: WINEVTLOG
      enabled: true
    tcp_address: 0.0.0.0:30001
    connection_timeout_sec: 60

規則運算式篩選器

規則運算式篩選器可讓您根據原始記錄資料的比對模式篩選記錄。篩選器採用 RE2 語法。篩選器必須包含規則運算式,並視需要定義符合條件時的行為。

比對相符時的預設行為是 block。您可以使用 allow 行為指定篩選器。如果指定 allow 篩選器,轉送工具會封鎖不符合至少一個 allow 篩選器的記錄。

您可以定義任意數量的篩選器。Block 篩選器的優先順序高於 allow 篩選器。

定義篩選器時,必須為其指派名稱。系統會透過轉寄站健康指標,將有效篩選器的名稱回報給 Google SecOps。在設定根層級定義的篩選器,會與在收集器層級定義的篩選器合併。如果名稱衝突,則以收集器層級篩選器為準。如果根層級或收集器層級未定義任何篩選器,則預設行為是允許所有記錄。

範例設定

在下列轉送站設定中,系統會封鎖與根篩選器 (allow_filter) 不符的 WINEVTLOG 記錄。根據規則運算式,篩選器只允許優先順序介於 0 到 99 之間的記錄。不過,任何含有「foo」或「bar」的 NIX_SYSTEM 記錄都會遭到封鎖,即使有 allow_filter 也一樣。這是因為篩選器使用邏輯 OR。所有記錄都會經過處理,直到觸發篩選器為止。

regex_filters:
  allow_filter:
    regexp: ^<[1-9][0-9]?$>.*$
    behavior_on_match: allow
collectors:
- syslog:
    common:
      regex_filters:
        block_filter_1:
          regexp: ^.*foo.*$
          behavior_on_match: block
        block_filter_2:
          regexp: ^.*bar.*$
      batch_n_bytes: 1048576
      batch_n_seconds: 10
      data_hint: null
      data_type: NIX_SYSTEM
      enabled: true
    tcp_address: 0.0.0.0:30000
    connection_timeout_sec: 60
- syslog:
    common:
      batch_n_bytes: 1048576
      batch_n_seconds: 10
      data_hint: null
      data_type: WINEVTLOG
      enabled: true
    tcp_address: 0.0.0.0:30001
    connection_timeout_sec: 60

任意標籤

標籤用於透過鍵/值組合,將自訂中繼資料附加至記錄。您可以為整個轉寄站或轉寄站中的特定收集器設定標籤。如果兩者都存在,且鍵重疊,則收集器層級標籤會覆寫轉送器層級標籤。

範例設定

在下列轉寄站設定中,「foo=bar」和「meow=mix」鍵/值組合都會附加至 WINEVTLOG 記錄,「foo=baz」和「meow=mix」鍵/值組合則會附加至 NIX_SYSTEM 記錄。

metadata:
  labels:
    foo: bar
    meow: mix
collectors:
syslog:
    common:
      metadata:
        labels:
          foo: baz
          meow: mix
      batch_n_bytes: 1048576
      batch_n_seconds: 10
      data_hint: null
      data_type: NIX_SYSTEM
      enabled: true
    tcp_address: 0.0.0.0:30000
    connection_timeout_sec: 60
syslog:
    common:
      batch_n_bytes: 1048576
      batch_n_seconds: 10
      data_hint: null
      data_type: WINEVTLOG
      enabled: true
    tcp_address: 0.0.0.0:30001
    connection_timeout_sec: 60

命名空間

您可以依據命名空間標籤識別來自不同網路區段的記錄,並解決 IP 位址重疊的情況。為轉寄站設定的任何命名空間,都會與相關聯的資產一起顯示在 Google SecOps 使用者介面中。您也可以使用 Google SecOps 搜尋功能搜尋命名空間。

如要瞭解如何在 Google SecOps 使用者介面中查看命名空間,請參閱「資產命名空間」。

範例設定

在下列轉寄站設定中,WINEVTLOG 記錄會附加至 FORWARDER 命名空間,NIX_SYSTEM 記錄則會附加至 CORPORATE 命名空間。

metadata:
  namespace: FORWARDER
collectors:
- syslog:
      common:
        metadata:
          namespace: CORPORATE
        batch_n_bytes: 1048576
        batch_n_seconds: 10
        data_hint: null
        data_type: NIX_SYSTEM
        enabled: true
      tcp_address: 0.0.0.0:30000
      connection_timeout_sec: 60
- syslog:
      common:
        batch_n_bytes: 1048576
        batch_n_seconds: 10
        data_hint: null
        data_type: WINEVTLOG
        enabled: true
      tcp_address: 0.0.0.0:30001
      connection_timeout_sec: 60

負載平衡和高可用性選項

您可以在轉寄站設定檔的伺服器部分,設定 HTTP 伺服器、負載平衡和高可用性選項。這些選項支援設定逾時時間長度和狀態碼,以回應容器排程器和基於自動調度管理部署作業,以及負載平衡器收到的健康狀態檢查。

請使用下列網址路徑,檢查健康狀態、readiness 和 liveness。<host:port> 值是在轉寄站設定中定義。

  • http://<host:port>/meta/available::容器 排程器或自動調度管理工具的活躍度檢查
  • http://<host:port>/meta/ready:Readiness 檢查和負載平衡器健康狀態檢查

以下轉送站設定是負載平衡和高可用性的範例:

collectors:
- syslog:
    common:
      batch_n_bytes: 1048576
      batch_n_seconds: 10
      data_hint: null
      data_type: NIX_SYSTEM
      enabled: true
    tcp_address: 0.0.0.0:30000
    connection_timeout_sec: 60
- syslog:
    common:
      batch_n_bytes: 1048576
      batch_n_seconds: 10
      data_hint: null
      data_type: WINEVTLOG
      enabled: true
    tcp_address: 0.0.0.0:30001
    connection_timeout_sec: 60
server:
  graceful_timeout: 15s
  drain_timeout: 10s
  http:
    port: 8080
    host: 0.0.0.0
    read_timeout: 3s
    read_header_timeout: 3s
    write_timeout: 3s
    idle_timeout: 3s
    routes:
    - meta:
        available_status: 204
        ready_status: 204
        unready_status: 503
設定路徑 說明
server : graceful_timeout 轉送器傳回不良的 readiness/健康狀態檢查,且仍接受新連線的時間長度。這也是收到停止信號到實際開始關閉伺服器之間的等待時間。這樣負載平衡器就有時間從集區中移除轉送器。
server : drain_timeout 轉送站等待有效連線自行關閉的時間長度,超過這個時間後,伺服器就會關閉連線。
server : http : port HTTP 伺服器監聽負載平衡器健康狀態檢查的通訊埠編號。必須介於 1024 至 65535 之間。
server : http : host 伺服器應監聽的 IP 位址,或可解析為 IP 位址的主機名稱。如果留空,預設值為本機系統 (0.0.0.0)。
server : http : read_timeout 用於調整 HTTP 伺服器。通常不需要變更預設設定。讀取整個要求 (包括標頭和主體) 的時間上限。您可以同時設定 read_timeout 和 read_header_timeout。
server : http : read_header_timeout 用於調整 HTTP 伺服器。通常不需要變更預設設定。讀取要求標頭的時間上限。讀取標頭後,連線的讀取期限會重設。
server : http : write_timeout 用於調整 HTTP 伺服器。通常不需要變更預設設定。傳送回應的時間上限。讀取新的要求標頭時,系統會重設這個值。
server : http : idle_timeout 用於調整 HTTP 伺服器。通常不需要變更預設設定。啟用閒置連線時,等待下一個要求的最長時間。如果 idle_timeout 為零,則會使用 read_timeout 的值。如果兩者皆為零,則會使用 read_header_timeout。
routes : meta : ready_status 轉送器準備好在下列任一情況下接受流量時,會傳回的狀態碼:
  • 容器排程器或自動調度管理工具會傳送就緒檢查。
  • 健康狀態檢查來自傳統負載平衡器。
routes : meta : unready_status 轉送器尚未準備好接受流量時,傳回的狀態碼。
routes : meta : available_status 轉送器收到有效性檢查且可用時,會傳回的狀態碼。容器排程器或自動調度管理工具通常會傳送存活狀態檢查。

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