收集 NGINX 記錄
本文說明如何使用 Bindplane 代理程式,將 NGINX 記錄擷取至 Google Security Operations。
NGINX 是網路伺服器和反向 Proxy,可為 HTTP 存取事件、錯誤事件、驗證活動和程序資訊產生系統記錄訊息。剖析器會使用 Grok 模式從多種記錄格式 (系統記錄、JSON、存取記錄) 中擷取欄位,並將這些欄位對應至統合式資料模型 (UDM)。
事前準備
請確認您已完成下列事前準備事項:
- Google SecOps 執行個體
- Windows Server 2016 以上版本,或搭載
systemd的 Linux 主機 - Bindplane 代理程式與 NGINX 伺服器之間的網路連線
- 如果透過 Proxy 執行,請確保防火牆通訊埠已根據 Bindplane 代理程式需求開啟
- NGINX 主機的管理員存取權
取得 Google SecOps 擷取驗證檔案
- 登入 Google SecOps 控制台。
- 依序前往「SIEM 設定」>「收集代理程式」。
- 下載擷取驗證檔案。
將檔案安全地儲存在要安裝 Bindplane 代理程式的系統上。
取得 Google SecOps 客戶 ID
- 登入 Google SecOps 控制台。
- 依序前往「SIEM 設定」>「設定檔」。
複製並儲存「機構詳細資料」部分中的客戶 ID。
安裝 Bindplane 代理程式
請按照下列操作說明,在 Windows 或 Linux 作業系統上安裝 Bindplane 代理程式。
Windows 安裝
- 以管理員身分開啟「命令提示字元」或「PowerShell」。
執行下列指令:
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet等待安裝完成。
執行下列指令,確認安裝成功:
sc query observiq-otel-collector服務應顯示為「RUNNING」。
Linux 安裝
- 開啟具有根層級或 sudo 權限的終端機。
執行下列指令:
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh等待安裝完成。
執行下列指令,確認安裝成功:
sudo systemctl status observiq-otel-collector服務應顯示為有效 (執行中)。
其他安裝資源
如需其他安裝選項和疑難排解資訊,請參閱 Bindplane 代理程式安裝指南。
設定 Bindplane 代理程式,擷取系統記錄檔並傳送至 Google SecOps
找出設定檔
Linux:
sudo nano /opt/observiq-otel-collector/config.yamlWindows:
notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
編輯設定檔
將
config.yaml的所有內容替換為下列設定:receivers: udplog: listen_address: "0.0.0.0:514" exporters: chronicle/nginx: compression: gzip creds_file_path: '/etc/bindplane-agent/ingestion-auth.json' customer_id: '<customer_id>' endpoint: malachiteingestion-pa.googleapis.com log_type: NGINX raw_log_field: body service: pipelines: logs/nginx_to_chronicle: receivers: - udplog exporters: - chronicle/nginx
設定參數
替換下列預留位置:
接收器設定:
listen_address:要接聽的 IP 位址和通訊埠:0.0.0.0,監聽所有介面 (建議)- 通訊埠
514是標準的系統記錄通訊埠 (在 Linux 上需要根層級權限;非根層級權限請使用1514)
匯出工具設定:
creds_file_path:擷取驗證檔案的完整路徑:- Linux:
/etc/bindplane-agent/ingestion-auth.json - Windows:
C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
- Linux:
customer_id:從 Google SecOps 控制台複製的客戶 IDendpoint:區域端點網址:- 美國:
malachiteingestion-pa.googleapis.com - 歐洲:
europe-malachiteingestion-pa.googleapis.com - 亞洲:
asia-southeast1-malachiteingestion-pa.googleapis.com - 如需完整清單,請參閱「區域端點」
- 美國:
儲存設定檔
- 編輯完成後,請儲存檔案:
- Linux:依序按下
Ctrl+O、Enter和Ctrl+X - Windows:依序點選「檔案」>「儲存」
- Linux:依序按下
重新啟動 Bindplane 代理程式,以套用變更
如要在 Linux 中重新啟動 Bindplane 代理程式,請執行下列指令:
sudo systemctl restart observiq-otel-collector確認服務正在執行:
sudo systemctl status observiq-otel-collector檢查記錄中是否有錯誤:
sudo journalctl -u observiq-otel-collector -f
如要在 Windows 中重新啟動 Bindplane 代理程式,請選擇下列其中一個選項:
以管理員身分開啟命令提示字元或 PowerShell:
net stop observiq-otel-collector && net start observiq-otel-collector服務控制台:
- 按下
Win+R,輸入services.msc,然後按下 Enter 鍵。 - 找出 observIQ OpenTelemetry Collector。
- 按一下滑鼠右鍵,然後選取「重新啟動」。
確認服務正在執行:
sc query observiq-otel-collector檢查記錄中是否有錯誤:
type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
- 按下
設定 NGINX 將記錄檔轉送至 Bindplane
開啟 NGINX 設定檔 (例如
/etc/nginx/nginx.conf):sudo vi /etc/nginx/nginx.conf編輯設定,將
<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; }重新啟動 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 剖析,擷取 time、method、target_path、protocol、response_code、referral_url、user_agent、target_ip、target_host 和 cache |
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.hostname 或 principal.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,然後可能會根據其他欄位 (例如 terminal 和 protocol) 覆寫。如果主要 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 |
如果 terminal 為 sshd 或 ssh,或主要 grok 模式不符,請設為 TCP |
|
principal.asset_id |
如果 terminal 為 sshd 或 ssh,請設為 GCP.GCE:0001。如果主要 grok 模式不符,請設為 GCP.GCE:0002 |
|
extensions.auth.type |
如果 terminal 為 sshd 或 ssh,請設為 MACHINE |
|
log_hostname |
event.idm.read_only_udm.principal.asset.hostname |
從變更記錄對應 |
ip_part |
event.idm.read_only_udm.intermediary.ip |
從變更記錄對應 |
domain_part |
event.idm.read_only_udm.intermediary.administrative_domain |
從變更記錄對應 |
location_part |
event.idm.read_only_udm.intermediary.location.name |
從變更記錄對應 |
labels.compute_googleapis_com/resource_name |
event.idm.read_only_udm.target.hostname |
從變更記錄對應 |
resource.labels.instance_id |
event.idm.read_only_udm.target.resource.product_object_id |
從變更記錄對應 |
resource.labels.project_id |
event.idm.read_only_udm.target.resource_ancestors.name |
從變更記錄對應 |
resource.labels.zone |
event.idm.read_only_udm.target.resource.attribute.cloud.availability_zone |
從變更記錄對應 |
resource.type |
event.idm.read_only_udm.target.resource.resource_type |
從變更記錄對應 |
insertId |
event.idm.read_only_udm.metadata.product_log_id |
從變更記錄對應 |
jsonPayload.latency |
event.idm.read_only_udm.additional.fields |
從變更記錄對應 |
remoteIp |
event.idm.read_only_udm.target.ip |
從變更記錄對應 |
jsonPayload.requestMethod |
event.idm.read_only_udm.network.http.method |
從變更記錄對應 |
jsonPayload.requestSize |
event.idm.read_only_udm.network.sent_bytes |
從變更記錄對應 |
jsonPayload.requestUrl |
event.idm.read_only_udm.network.http.referral_url |
從變更記錄對應 |
jsonPayload.responseSize |
event.idm.read_only_udm.network.received_bytes |
從變更記錄對應 |
jsonPayload.serverIp |
event.idm.read_only_udm.target.ip |
從變更記錄對應 |
jsonPayload.status |
event.idm.read_only_udm.network.http.response_code |
從變更記錄對應 |
jsonPayload.userAgent |
event.idm.read_only_udm.network.http.user_agent |
從變更記錄對應 |
jsonPayload.userAgent |
event.idm.read_only_udm.network.http.parsed_user_agent |
從變更記錄對應 |
labels |
event.idm.read_only_udm.additional.fields |
從變更記錄對應 |
terminal |
event.idm.read_only_udm.additional.fields |
從變更記錄對應 |
logName |
event.idm.read_only_udm.additional.fields |
從變更記錄對應 |
resource.labels |
event.idm.read_only_udm.target.resource.attribute.labels |
從變更記錄對應 |
resource.type |
event.idm.read_only_udm.target.resource.attribute.labels |
從變更記錄對應 |
resource.name |
event.idm.read_only_udm.target.resource.name |
從變更記錄對應 |
timestamp |
event.idm.read_only_udm.metadata.event_timestamp |
從變更記錄對應 |
user_agent |
event.idm.read_only_udm.network.http.parsed_user_agent |
從變更記錄對應 |
變更記錄
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。