Collect NGINX logs

Supported in:

This NGINX parser handles JSON and syslog formatted logs. It extracts fields from various log formats and normalizes them into the UDM format. The parser enriches the event with metadata for server management and network activity, including user logins and HTTP requests. It also handles logic for SSH events and populates UDM fields based on extracted data.

Before you begin

  • Ensure that you have a Google Security Operations instance.
  • Ensure NGINX is running and generating logs.
  • Ensure that you have root access to NGINX host machine.

Get Google SecOps ingestion authentication file

  1. Sign in to the Google SecOps console.
  2. Go to SIEM Settings > Collection Agents.
  3. Download the Ingestion Authentication File.

Get Google SecOps customer ID

  1. Sign in to the Google SecOps console.
  2. Go to SIEM Settings > Profile.
  3. Copy and save the Customer ID from the Organization Details section.

Install BindPlane Agent

  1. For Windows installation, run the following script:
    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
  2. For Linux installation, run the following script:
    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
  3. Additional installation options can be found in this installation guide.

Configure the BindPlane Agent to ingest Syslog and send to Google SecOps

  1. Access the machine where BindPlane is installed.
  2. Edit the config.yaml file as follows:

    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
    
  3. Restart the BindPlane Agent to apply the changes:

    sudo systemctl restart bindplane
    

Identify NGINX log files location

NGINX logs are stored in: * Access logs: /var/log/nginx/access.log * Error logs: /var/log/nginx/error.log 1. Access the NGINX host using administrative credentials. 1. Run the following command and look for the log file paths on your NGINX host:

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

Configure NGINX to Forward Logs to Bindplane

  1. Open the NGINX configuration file (for example, /etc/nginx/nginx.conf):

    sudo vi /etc/nginx/nginx.conf
    
  2. Edit the configuration, replacing <BINDPLANE_SERVER> and <BINDPLANE_PORT> with your values:

    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. Restart NGINX to apply the changes:

    sudo systemctl reload nginx
    

UDM Mapping Table

Log Field UDM Mapping Logic
_Internal_WorkspaceResourceId target.resource.product_object_id Directly mapped
Computer principal.asset.hostname Directly mapped
Facility additional.fields["facility"] Directly mapped
HostName principal.asset.hostname Directly mapped if src_ip is not present
ProcessName principal.application Directly mapped
SeverityLevel security_result.severity Mapped to INFORMATIONAL if the value is "info"
SourceSystem principal.asset.platform Mapped to LINUX if the value matches "Linux"
SyslogMessage Multiple fields Parsed using grok to extract time, method, target_path, protocol, response_code, referral_url, user_agent, target_ip, target_host, and cache
TenantId additional.fields["TenantId"] Directly mapped
acct principal.user.user_id Directly mapped if not empty or "?"
addr principal.asset.ip Directly mapped
audit_epoch metadata.event_timestamp Converted to timestamp using the "UNIX" format. Nanoseconds are extracted from the original log message.
cache additional.fields["cache"] Directly mapped
collection_time.nanos metadata.event_timestamp.nanos Used for nanoseconds of the event timestamp if available
collection_time.seconds metadata.event_timestamp.seconds Used for seconds of the event timestamp if available
data Multiple fields The main source of data, parsed differently based on the log format (Syslog, JSON, or other)
exe target.process.command_line Directly mapped after removing backslashes and quotes
hostname principal.asset.hostname OR principal.asset.ip If it is an IP address, mapped to principal.asset.ip. Otherwise, mapped to principal.asset.hostname
msg metadata.description Directly mapped as the description
node target.asset.hostname Directly mapped
pid target.process.pid Directly mapped
protocol network.application_protocol Mapped to HTTP if the value matches "HTTP"
referral_url network.http.referral_url Directly mapped if not empty or "-"
res security_result.action_details Directly mapped
response_code network.http.response_code Directly mapped and converted to integer
ses network.session_id Directly mapped
src_ip principal.asset.ip Directly mapped
target_host target.asset.hostname Directly mapped
target_ip target.asset.ip Directly mapped, after converting the string representation to a JSON array and then extracting individual IPs
target_path target.url Directly mapped
time metadata.event_timestamp Parsed to extract the timestamp using the format "dd/MMM/yyyy:HH:mm:ss Z"
user_agent network.http.user_agent Directly mapped if not empty or "-"
metadata.event_type Set to "GENERIC_EVENT" initially, then potentially overwritten based on other fields like terminal and protocol. Defaults to "USER_UNCATEGORIZED" if the main grok pattern does not match. Set to "NETWORK_HTTP" if protocol is HTTP and target_ip is present, and "STATUS_UPDATE" if protocol is HTTP but target_ip is not present
metadata.log_type Set to "NGINX"
metadata.product_name Set to "NGINX"
metadata.vendor_name Set to "NGINX"
network.ip_protocol Set to "TCP" if terminal is "sshd" or "ssh", or if the main grok pattern does not match
principal.asset_id Set to "GCP.GCE:0001" if terminal is "sshd" or "ssh". Set to "GCP.GCE:0002" if the main grok pattern does not match
extensions.auth.type Set to "MACHINE" if terminal is "sshd" or "ssh"

Changes

2022-09-10

  • Created a default parser and deleted the customer-specific parser.
  • Initial parser release.