NXLog Docs

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 structured 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 can work in one of two configured modes: structured and unstructured, which are specified by the ChronicleMode directive.

The om_chronicle module accepts the following directives in addition to the common module directives.

HTTP(S) directives

The following directives are for configuring HTTP(S) connection settings.

AddHeader

This optional directive can be specified multiple times to add custom headers to each HTTP request.

Compression

This optional directive can be used to enable HTTP compression for outgoing HTTP messages. The possible values are none, gzip, and deflate. By default, compression is disabled. Please note that some HTTP servers may not accept compressed HTTP requests. If a server doesn’t support a specific compression method, it may return 415 Unsupported Media Type errors in response to compressed requests.

HTTPBasicAuthUser

HTTP basic authorization username. You must also set the HTTPBasicAuthPassword directive to use HTTP authorization.

HTTPBasicAuthPassword

HTTP basic authorization password. You must also set the HTTPBasicAuthUser directive to use HTTP authorization.

HTTPSAllowExpired

This boolean directive specifies whether the connection should be allowed with an expired certificate. If set to TRUE, the remote client will be able to connect with an expired certificate. The default is FALSE: the certificate must not be expired. This directive is only valid if HTTPSRequireCert is set to TRUE.

HTTPSAllowUntrusted

This boolean directive specifies that the connection should be allowed without certificate verification. If set to TRUE, the connection will be allowed even if the remote client presents an unknown or self-signed certificate. The default value is FALSE: the remote client 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 client. A remote client’s self-signed certificate (which is not signed by a CA) can be trusted by specifying the remote client certificate itself. In the case of certificates signed by an intermediate CA, the certificate specified must contain the complete certificate chain (certificate bundle).

HTTPSCertFile

This specifies the path of the certificate file that will be presented to the remote client 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.

Proxy

This optional directive is used to specify the protocol, IP address (or hostname) and port number of the HTTP or SOCKS proxy server to be used. The format is protocol://hostname:port.

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.

Optional directives

ChronicleBatchSize

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: structured or unstructured (unstructured is the default).

unstructured: this mode supports forwarding unstructured logs to the v1/unstructuredlogentries endpoint. Your unstructured log data is normalized within the Chronicle infrastructure and made available to you through the Chronicle UI. However, some information may be difficult to extract from the unstructured log data and might only be searchable using Raw Log Scan. Also requires LogType to be set.

structured: This mode supports forwarding logs to the v1/udmevents endpoint. If you have formatted your log data using Chronicle’s UDM, you can forward UDM events to your Chronicle account using the UDM API endpoint. Since UDM events are standardized, Chronicle is better able to process and interpret the data, increasing Chronicle’s ability to recognize security compromises and threats within your enterprise.

ChronicleRegion

This directive specifies a regional endpoint. Supported values are: US, Europe, asia-southeast1, etc. See the Locations page.

ChronicleSchema

The output data from each NXLog module is mapped to Chronicle UDM using custom mapping schemas. This directive allows to specify another schema file to override the default mapping.

This directive is only for Structured mode, and is not used in Unstructured mode. See ChronicleMode directive.

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.

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 in Unstructured mode, and is not used in Structured mode. See ChronicleMode directive.

URL

Optional directive for specifying 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.

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

    HTTPSAllowUntrusted   TRUE

    <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

    HTTPSAllowUntrusted   TRUE

</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"
    }
  ]
}