NXLog Legacy Documentation

Google Chronicle (om_chronicle)

Google Chronicle is a cloud service built as a specialized layer on top of the core Google infrastructure. It is designed for enterprises to privately retain, analyze, and search the massive amounts of security and network telemetry they generate. Chronicle normalizes, indexes, correlates, and analyzes the data to provide instant analysis and context on risky activity.

The Chronicle Ingestion API enables you to forward logs directly to Chronicle. This module supports forwarding logs to the v1/udmevents and v1/unstructuredlogentries endpoints. Event data is sent in batches, thus reducing HTTP response latency and improving data throughput.

This module currently works with the Google Chronicle v1 API which requires a Chronicle Ingestion API access key. Chronicle API v2 with Google Developer Service Accounts that use OAuth 2.0 authentication will be supported soon.
To examine the supported platforms, see the list of installer packages in the Available Modules chapter.

Unstructured logs output format

om_chronicle forwards unstructured log records over HTTP(S) as JSON payload in the following format:

{
    "log_type": "<log_type>",
    "customer_id": "<customer_id>",
    "entries": [
        {
            "log_text": "<json_escaped_raw_event>",
            "ts_rfc3339": "<event_time>"
        }
    ]
}

For example:

{
    "log_type": "BIND_DNS",
    "customer_id": "c8c65bfa-5f2c-42d4-9189-64bb7b939f2c",
    "entries": [
        {
            "log_text": "26-Feb-2019 13:37:04.523 client 10.50.100.33#1116: query: examplepetstore.com IN A + (203.0.113.102)",
            "ts_rfc3339": "2019-26-02T13:37:04.523-08:00"
        },
        {
            "log_text": "26-Feb-2019 13:39:01.115 client 10.1.2.3#3333: query: www.example.com IN A + (203.0.113.102)"
        }
    ]
}

Required fields:

  • log_type is the value specified by the LogType directive.

  • log_text is the JSON escaped value of the $raw_event field.

Optional fields:

  • customer_id is present if the CustomerId directive is specified.

  • ts_rfc3339 is present if the $EventReceivedTime core field is present. If this field is not required, use the delete() procedure to remove $EventReceivedTime. This can be useful if the log text already contains a received date and time.

Additional metadata, including the NXLog-specific fields $SourceModuleName and $SourceModuleType, will not be included in the output unless these values have been written to the $raw_event field. The processing required to achieve this depends on the format of the input data. For example, if the input data is in JSON format, you need to:

  1. Use parse_json() to parse $raw_event into fields.

  2. Create and populate any additional custom fields.

  3. Use to_json() to convert the fields to JSON format and update the value of $raw_event.

Structured logs output format

om_chronicle forwards structured log records over HTTP(S) as JSON payload in the following format:

{
    "metadata": {
        "event_type": "NETWORK_CONNECTION",
        "event_timestamp": "<event_time>",
        "description": "<json_escaped_raw_event>",
        "ingestion_labels": [
            {
                "key": "source_module_name",
                "value": "<source_module_name>"
            },
            {
                "key": "source_module_type",
                "value": "<source_module_type>"
            }
        ]
    },
    "network": {
        "ip_protocol": "TCP"
    },
    "principal": {
        "ip": "<message_source_address>"
    },
    "target": {
        "application": "nxlog",
        "ip": "127.0.0.1"
    }
}

For example:

{
    "metadata": {
        "description": "16-May-2022 20:11:15.187 client 10.120.20.20#4238:  query: example.com IN A + (100.90.80.102)",
        "event_timestamp": "2023-03-16T10:44:27.421707+05:45",
        "event_type": "NETWORK_CONNECTION",
        "ingestion_labels": [
            {
                "key": "source_module_name",
                "value": "tcp"
            },
            {
                "key": "source_module_type",
                "value": "im_tcp"
            }
        ]
    },
    "network": {
        "ip_protocol": "TCP"
    },
    "principal": {
        "ip": "127.0.0.1"
    },
    "target": {
        "application": "nxlog",
        "ip": "127.0.0.1"
    }
}

Required fields:

  • description is the JSON escaped value of the $raw_event field.

  • event_timestamp is the value of $EventReceivedTime.

  • ingestion_labels.source_module_name is the value of $SourceModuleName, i.e., the name of the NXLog input module instance.

  • ingestion_labels.source_module_type is the value of $SourceModuleType, i.e., the NXLog input module.

If you remove any of these fields from the log record, for example, with the delete() procedure, the field value will be set to an empty string.

Configuration

The om_chronicle module supports two configuration modes: structured and unstructured, specified by the ChronicleMode directive. In addition, it accepts the following directives and the common module directives.

URL

Use this directive to explicitly specify the Chronicle Ingestion API endpoint.

Alternatively, use the optional ChronicleRegion, ChronicleMode, and ChronicleKey directives to use the default endpoint: https://{ChronicleRegion}-malachiteingestion-pa.googleapis.com/{ChronicleVersion}/{ChronicleMode}/?key={ChronicleKey}

Depending on the URL provided, the module operates in plain HTTP or HTTPS mode. If you do not specify the port number in the URL, it uses port 80 for HTTP and port 443 for HTTPS.

ChronicleVersion defaults to v1. Other values are not supported at this time.
This module does not support specifying multiple URL directives as a failover configuration.
OutputRequestSize

This optional directive specifies the recommended size (in bytes) of each batch of log data. The maximum size for unstructured logs is 1 MB (1,048,576 bytes).

ChronicleMode

This directive specifies the Google Chronicle API endpoint. The supported values are structured or unstructured. The default is unstructured.

unstructured

This mode supports forwarding unstructured logs to the v1/unstructuredlogentries endpoint. Google Chronicle normalizes the log data and makes it available through the Chronicle UI. However, Google Chronicle might not be able to parse unstructured logs entirely, and they will only be searchable using Raw Log Scan. When sending unstructured logs, you must also specify the LogType.

structured

This mode supports forwarding logs to the v1/udmevents endpoint. Use this endpoint to send UDM-formatted log records to Google Chronicle. Since UDM is a standard format, Chronicle is better able to interpret the data, increasing Chronicle’s ability to detect security threats within your enterprise.

ChronicleRegion

Use this directive to specify a regional endpoint, for example, us-east1, europe, asia-southeast1, etc. See the Google Cloud locations page for a list of available regions.

ChronicleSchema

This module converts logs collected by NXLog modules to Chronicle UDM using a custom mapping. Use this directive to specify a schema file to override the default mapping. It only applies when sending structured log entries and is not used when sending unstructured logs. See the ChronicleMode directive.

Compression

This optional directive can be used to enable HTTP compression for outgoing HTTP messages. The possible values are none and gzip for Google Chronicle. By default, compression is disabled.

CustomerId

This directive specifies a valid unique identifier (UUID) corresponding to a particular Chronicle instance. Chronicle responds with HTTP error 400 or 403 if this UUID is not valid.

HTTPSAllowExpired

This boolean directive specifies whether the connection should be allowed with an expired certificate. If set to TRUE, the connection will be allowed even if the remote server presents an expired certificate. The default is FALSE: the remote server must present a certificate that is not expired.

HTTPSAllowUntrusted

This boolean directive specifies that the connection should be allowed regardless of the certificate verification results. If set to TRUE, the connection will be allowed with any unexpired certificate provided by a server. The default value is FALSE: the remote server must present a trusted certificate.

HTTPSCADir

This directive specifies a path to a directory containing certificate authority (CA) certificates. These certificates will be used to verify the certificate presented by the remote server. The certificate files must be named using the OpenSSL hashed format, i.e. the hash of the certificate followed by .0, .1 etc. To find the hash of a certificate using OpenSSL:

$ openssl x509 -hash -noout -in ca.crt

For example, if the certificate hash is e2f14e4a, then the certificate filename should be e2f14e4a.0. If there is another certificate with the same hash then it should be named e2f14e4a.1 and so on.

A remote server’s self-signed certificate (which is not signed by a CA) can also be trusted by including a copy of the certificate in this directory.

The default operating system root certificate store will be used if this directive is not specified. Unix-like operating systems commonly store root certificates in /etc/ssl/certs. Windows operating systems use the Windows Certificate Store, while macOS uses the Keychain Access Application as the default certificate store. See NXLog TLS/SSL configuration in the User Guide for more information on using this directive.

HTTPSCAFile

This specifies the path of the certificate authority (CA) certificate that will be used to verify the certificate presented by the remote server. A remote server’s self-signed certificate (which is not signed by a CA) can be trusted by specifying the remote server certificate itself. In case of certificates signed by an intermediate CA, the certificate specified must contain the complete certificate chain (certificate bundle).

HTTPSCAThumbprint

This optional directive specifies the thumbprint of the certificate authority (CA) certificate that will be used to verify the certificate presented by the remote server. The hexadecimal fingerprint string can be copied from Windows Certificate Manager (certmgr.msc). Whitespaces are automatically removed. The certificate must be imported to the certificate store accessible by NXLog user for NXLog to find it. This directive is only supported on Windows and is mutually exclusive with the HTTPSCADir and HTTPSCAFile directives.

HTTPSSearchAllCertStores

This optional boolean directive can be used to load all the possible certificates found in the Windows Certificate Store accessible by the user running NXLog. This directive is mutually exclusive with the HTTPSCAThumbprint, HTTPSCADir and HTTPSCAFile directives.

HTTPSCertFile

This specifies the path of the certificate file that will be presented to the remote server during the HTTPS handshake.

HTTPSCertKeyFile

This specifies the path of the private key file that was used to generate the certificate specified by the HTTPSCertFile directive. This is used for the HTTPS handshake.

HTTPSCertThumbprint

This optional directive specifies the thumbprint of the certificate that will be presented to the remote server during the HTTPS handshake. The hexadecimal fingerprint string can be copied from Windows Certificate Manager (certmgr.msc). Whitespaces are automatically removed. The certificate must be imported to the Local Computer\Personal certificate store in PFX format for NXLog to find it. To create a PFX file from the certificate and private key using OpenSSL:

$ openssl pkcs12 -export -out server.pfx -inkey server.key -in server.pem

This directive is only supported on Windows and is mutually exclusive with the HTTPSCertFile and HTTPSCertKeyFile directives.

The private key associated with the certificate must be exportable.

  • If you generate the certificate request using Windows Certificate Manager, enable the Make private key exportable option from the certificate properties.

  • If you import the certificate with the Windows Certificate Import Wizard, make sure that the Mark this key as exportable option is enabled.

  • If you migrate the certificate and associated private key from one Windows machine to another, select Yes, export the private key when exporting from the source machine.

HTTPSCRLDir

This directive specifies a path to a directory containing certificate revocation list (CRL) files. These CRL files will be used to check for certificates that were revoked and should no longer be accepted. The files must be named using the OpenSSL hashed format, i.e. the hash of the issuer followed by .r0, .r1 etc. To find the hash of the issuer of a CRL file using OpenSSL:

$ openssl crl -hash -noout -in crl.pem

For example if the hash is e2f14e4a, then the filename should be e2f14e4a.r0. If there is another file with the same hash then it should be named e2f14e4a.r1 and so on.

HTTPSCRLFile

This specifies the path of the certificate revocation list (CRL) which will be used to check for certificates that have been revoked and should no longer be accepted. Example to generate a CRL file using OpenSSL:

$ openssl ca -gencrl -out crl.pem
HTTPSKeyPass

This directive specifies the passphrase of the private key specified by the HTTPSCertKeyFile directive. A passphrase is required when the private key is encrypted. Example to generate a private key with Triple DES encryption using OpenSSL:

$ openssl genrsa -des3 -out server.key 2048

This directive is not needed for passwordless private keys.

HTTPSSSLCompression

This boolean directive allows you to enable data compression when sending data over the network. The compression mechanism is based on the zlib compression library. If the directive is not specified, it defaults to FALSE: compression is disabled.

Some Linux packages (for example, Debian) use the OpenSSL library provided by the OS and may not support the zlib compression mechanism. The module will emit a warning on startup if the compression support is missing. The generic deb/rpm packages are bundled with a zlib-enabled libssl library.
LogType

Must correspond to a valid log type. To retrieve the list of possible log types, visit https://malachiteingestion-pa.googleapis.com/v1/logtypes?key=YOUR_API_KEY.

This directive is mandatory when sending unstructured logs and is not used when sending structured log entries. See the ChronicleMode directive.

Reconnect

This optional directive sets the reconnect interval in seconds. If it is set, the module attempts to reconnect in every defined second. If it is not set, the reconnect interval will start at 1 second and doubles on every attempt. If the duration of the successful connection is greater than the current reconnect interval, then the reconnect interval will be reset to 1 sec.

Examples

Example 1. Sending unstructured plain text logs

This configuration collects logs from a BIND 9 DNS server and forwards them to Chronicle. Since the BIND_DNS LogType requires the events to be in syslog format, log records are converted to syslog using the to_syslog_bsd() procedure of the xm_syslog module.

nxlog.conf
# Google Chronicle API key, required.
define API_KEY            <YOUR_API_KEY>

<Extension syslog>
    Module                xm_syslog
</Extension>

<Output unstructured>
    Module                om_chronicle

    # Google Chronicle API key, required.
    ChronicleKey          %API_KEY%

    # Unstructured events
    ChronicleMode         unstructured

    # Identifies the type of logs in the batch.
    LogType               BIND_DNS

    # Batch size in bytes (B), optional.
    ChronicleBatchSize    1024

    <Exec>
        $Message = $raw_event;
        to_syslog_bsd();
    </Exec>
</Output>

<Output structured>
    Module                om_chronicle

    # Google Chronicle API key, required.
    ChronicleKey          %API_KEY%

    # UDM events
    ChronicleMode         structured
</Output>
Input sample
16-May-2022 20:11:15.187 client 10.120.20.20#4238:  query: example.com IN A + (100.90.80.102)
16-May-2022 20:11:16.120 client 10.120.20.20#4238:  query: example.com IN A + (100.90.80.102)
16-May-2022 20:11:17.165 client 10.120.20.20#4238:  query: example.com IN A + (100.90.80.102)
Output sample

The following is the JSON-formatted log record that will be sent to Google Chronicle. Note that the ts_rfc3339 field is added by the module and specifies the time when the event was received (corresponds to $EventReceivedTime).

{
  "log_type": "BIND_DNS",
  "entries": [
    {
      "log_text": "<13>May 16 20:11:19 SERVER1 16-May-2022 20:11:15.187 client 10.120.20.20#4238:  query: example.com IN A + (100.90.80.102)",
      "ts_rfc3339": "2022-05-16T20:11:19.859211+02:00"
    },
    {
      "log_text": "<13>May 16 20:11:19 SERVER1 16-May-2022 20:11:16.120 client 10.120.20.20#4238:  query: example.com IN A + (100.90.80.102)",
      "ts_rfc3339": "2022-05-16T20:11:19.859219+02:00"
    },
    {
      "log_text": "<13>May 16 20:11:19 SERVER1 16-May-2022 20:11:17.165 client 10.120.20.20#4238:  query: example.com IN A + (100.90.80.102)",
      "ts_rfc3339": "2022-05-16T20:11:19.859223+02:00"
    }
  ]
}