NGINX 로그 수집
이 NGINX 파서는 JSON 및 syslog 형식의 로그를 처리합니다. 다양한 로그 형식에서 필드를 추출하고 UDM 형식으로 정규화합니다. 파서는 사용자 로그인 및 HTTP 요청을 비롯한 서버 관리 및 네트워크 활동에 관한 메타데이터로 이벤트를 보강합니다. 또한 SSH 이벤트의 로직을 처리하고 추출된 데이터를 기반으로 UDM 필드를 채웁니다.
시작하기 전에
- Google Security Operations 인스턴스가 있는지 확인합니다.
- NGINX가 실행 중이고 로그를 생성하는지 확인합니다.
- NGINX 호스트 머신에 대한 루트 액세스 권한이 있는지 확인합니다.
Google SecOps 처리 인증 파일 가져오기
- Google SecOps 콘솔에 로그인합니다.
- SIEM 설정 > 수집 에이전트로 이동합니다.
- 처리 인증 파일을 다운로드합니다.
Google SecOps 고객 ID 가져오기
- Google SecOps 콘솔에 로그인합니다.
- SIEM 설정 > 프로필로 이동합니다.
- 조직 세부정보 섹션에서 고객 ID를 복사하여 저장합니다.
BindPlane 에이전트 설치
- Windows 설치의 경우 다음 스크립트를 실행합니다.
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
- Linux 설치의 경우 다음 스크립트를 실행합니다.
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
- 추가 설치 옵션은 이 설치 가이드에서 확인할 수 있습니다.
syslog를 수집하고 Google SecOps로 전송하도록 BindPlane 에이전트 구성
- BindPlane이 설치된 머신에 액세스합니다.
다음과 같이
config.yaml
파일을 수정합니다.receivers: tcplog: # Replace the below port <54525> and IP <0.0.0.0> with your specific values listen_address: "0.0.0.0:54525" exporters: chronicle/chronicle_w_labels: compression: gzip # Adjust the creds location below according the placement of the credentials file you downloaded creds: '{ json file for creds }' # Replace <customer_id> below with your actual ID that you copied customer_id: <customer_id> endpoint: malachiteingestion-pa.googleapis.com # You can apply ingestion labels below as preferred ingestion_labels: log_type: SYSLOG namespace: auditd raw_log_field: body service: pipelines: logs/source0__chronicle_w_labels-0: receivers: - tcplog exporters: - chronicle/chronicle_w_labels
BindPlane 에이전트를 다시 시작하여 변경사항을 적용합니다.
sudo systemctl restart bindplane
NGINX 로그 파일 위치 식별
NGINX 로그는 다음 위치에 저장됩니다.
* 액세스 로그: /var/log/nginx/access.log
* 오류 로그: /var/log/nginx/error.log
1. 관리자 사용자 인증 정보를 사용하여 NGINX 호스트에 액세스합니다.
1. 다음 명령어를 실행하고 NGINX 호스트에서 로그 파일 경로를 찾습니다.
sudo cat /etc/nginx/nginx.conf | grep log
로그를 Bindplane로 전달하도록 NGINX 구성
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["cache"] |
직접 매핑됨 |
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'으로 설정 |
변경사항
2022-09-10
- 기본 파서를 만들고 고객별 파서를 삭제했습니다.
- 초기 파서 출시