收集 NGINX 記錄

支援的國家/地區:

這個 NGINX 剖析器會處理 JSON 和系統記錄格式的記錄。並從各種記錄檔格式中擷取欄位,然後將其正規化為 UDM 格式。剖析器會使用伺服器管理和網路活動的中繼資料 (包括使用者登入和 HTTP 要求),擴充事件。此外,這個外掛程式也會處理 SSH 事件的邏輯,並根據擷取的資料填入 UDM 欄位。

事前準備

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

  • Google SecOps 執行個體
  • NGINX 正在執行並產生記錄
  • NGINX 主機的根層級存取權

取得 Google SecOps 擷取驗證檔案

  1. 登入 Google SecOps 控制台。
  2. 依序前往「SIEM 設定」>「收集代理程式」
  3. 下載擷取驗證檔案。將檔案安全地儲存在要安裝 Bindplane 的系統上。

取得 Google SecOps 客戶 ID

  1. 登入 Google SecOps 控制台。
  2. 依序前往「SIEM 設定」>「設定檔」
  3. 複製並儲存「機構詳細資料」專區中的客戶 ID

安裝 Bindplane 代理程式

Windows 安裝

  1. 以系統管理員身分開啟「命令提示字元」或「PowerShell」
  2. 執行下列指令:

    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
    

Linux 安裝

  1. 開啟具有根層級或 sudo 權限的終端機。
  2. 執行下列指令:

    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
    

其他安裝資源

設定 Bindplane 代理程式,擷取系統記錄檔並傳送至 Google SecOps

  1. 存取設定檔:

    1. 找出 config.yaml 檔案。通常位於 Linux 的 /etc/bindplane-agent/ 目錄,或 Windows 的安裝目錄。
    2. 使用文字編輯器 (例如 nanovi 或記事本) 開啟檔案。
  2. 按照下列方式編輯 config.yaml 檔案:

    receivers:
        udplog:
            # Replace the port and IP address as required
            listen_address: "0.0.0.0:514"
    
    exporters:
        chronicle/chronicle_w_labels:
            compression: gzip
            # Adjust the path to the credentials file you downloaded in Step 1
            creds: '/path/to/ingestion-authentication-file.json'
            # Replace with your actual customer ID from Step 2
            customer_id: <customer_id>
            endpoint: malachiteingestion-pa.googleapis.com
            # Add optional ingestion labels for better organization
            ingestion_labels:
                log_type: 'NGINX'
                raw_log_field: body
    
    service:
        pipelines:
            logs/source0__chronicle_w_labels-0:
                receivers:
                    - udplog
                exporters:
                    - chronicle/chronicle_w_labels
    
  3. 視基礎架構需求,替換通訊埠和 IP 位址。

  4. <customer_id> 替換為實際的客戶 ID。

  5. /path/to/ingestion-authentication-file.json 更新為「取得 Google SecOps 擷取驗證檔案」一節中儲存驗證檔案的路徑。

重新啟動 Bindplane 代理程式,以套用變更

  • 如要在 Linux 中重新啟動 Bindplane 代理程式,請執行下列指令:

    sudo systemctl restart bindplane-agent
    
  • 如要在 Windows 中重新啟動 Bindplane 代理程式,可以使用「服務」控制台,或輸入下列指令:

    net stop BindPlaneAgent && net start BindPlaneAgent
    

找出 NGINX 記錄檔位置

  1. NGINX 記錄檔通常儲存在:
    • 存取記錄/var/log/nginx/access.log
    • 錯誤記錄/var/log/nginx/error.log
  2. 使用管理員憑證存取 NGINX 主機。
  3. 執行下列指令,找出 NGINX 主機上的記錄檔路徑:

    sudo cat /etc/nginx/nginx.conf | grep log
    

設定 NGINX 將記錄檔轉送至 Bindplane

  1. 開啟 NGINX 設定檔 (例如 /etc/nginx/nginx.conf):

    sudo vi /etc/nginx/nginx.conf
    
  2. 編輯設定,將 <BINDPLANE_SERVER><BINDPLANE_PORT> 替換成您的值:

    http {
        access_log syslog:server=<BINDPLANE_SERVER>:<BINDPLANE_PORT>,facility=local7,tag=nginx_access;
        error_log syslog:server=<BINDPLANE_SERVER>:<BINDPLANE_PORT>,facility=local7,tag=nginx_error;
    }
    
  3. 重新啟動 NGINX 以套用變更:

    sudo systemctl reload nginx
    

UDM 對應表

記錄欄位 UDM 對應 邏輯
_Internal_WorkspaceResourceId target.resource.product_object_id 直接對應
Computer principal.asset.hostname 直接對應
Facility additional.fields[facility] 直接對應
HostName principal.asset.hostname 如果沒有 src_ip,則直接對應
ProcessName principal.application 直接對應
SeverityLevel security_result.severity 如果值為 info,則對應至「INFORMATIONAL」
SourceSystem principal.asset.platform 如果值符合 Linux,則對應至 LINUX
SyslogMessage 多個欄位 使用 grok 剖析,擷取 timemethodtarget_pathprotocolresponse_codereferral_urluser_agenttarget_iptarget_hostcache
TenantId additional.fields[TenantId] 直接對應
acct principal.user.user_id 如果不是空白或 ?,則直接對應
addr principal.asset.ip 直接對應
audit_epoch metadata.event_timestamp 使用 UNIX 格式轉換為時間戳記。系統會從原始記錄訊息擷取奈秒。
cache additional.fields[快取] 直接對應
collection_time.nanos metadata.event_timestamp.nanos 如果有的話,用於事件時間戳記的奈秒
collection_time.seconds metadata.event_timestamp.seconds 如果有的話,用於事件時間戳記的秒數
data 多個欄位 主要資料來源,會根據記錄格式 (Syslog、JSON 或其他) 以不同方式剖析
exe target.process.command_line 移除反斜線和引號後直接對應
hostname principal.asset.hostnameprincipal.asset.ip 如果是 IP 位址,則會對應至 principal.asset.ip。否則會對應至 principal.asset.hostname
msg metadata.description 直接對應為說明
node target.asset.hostname 直接對應
pid target.process.pid 直接對應
protocol network.application_protocol 如果值符合 HTTP,則對應至 HTTP
referral_url network.http.referral_url 如果不是空白或 -,則直接對應
res security_result.action_details 直接對應
response_code network.http.response_code 直接對應並轉換為整數
ses network.session_id 直接對應
src_ip principal.asset.ip 直接對應
target_host target.asset.hostname 直接對應
target_ip target.asset.ip 直接對應,方法是將字串表示法轉換為 JSON 陣列,然後擷取個別 IP
target_path target.url 直接對應
time metadata.event_timestamp 剖析以使用 dd/MMM/yyyy:HH:mm:ss Z 格式擷取時間戳記
user_agent network.http.user_agent 如果不是空白或 -,則直接對應
metadata.event_type 一開始設為 GENERIC_EVENT,然後可能會根據 terminalprotocol 等其他欄位覆寫。如果主要 grok 模式不符,則預設值為 USER_UNCATEGORIZED。如果 protocol 為 HTTP 且 target_ip 存在,則設為 NETWORK_HTTP;如果 protocol 為 HTTP 但 target_ip 不存在,則設為 STATUS_UPDATE
metadata.log_type 設為 NGINX
metadata.product_name 設為 NGINX
metadata.vendor_name 設為 NGINX
network.ip_protocol 如果 terminalsshdssh,或主要 grok 模式不符,請設為 TCP
principal.asset_id 如果 terminalsshdssh,請設為 GCP.GCE:0001。如果主要 grok 模式不符,請設為 GCP.GCE:0002
extensions.auth.type 如果 terminalsshdssh,請設為 MACHINE

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