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 udmevents and unstructuredlogentries endpoints. Event data is sent in batches, thus reducing HTTP response latency and improving data throughput.
om_chronicle can send logs to Chronicle Ingestion API v1 and v2. API v1 requires a Chronicle Ingestion API access key. Although this method is deprecated, it still works when writing this documentation. API v2 requires a Google Developer Service Account for OAuth 2.0 authentication.
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": "<13>Oct 9 17:33:15 SERVER-1 09-Oct-2023 17:33:15.187 queries: info: client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)",
"ts_rfc3339": "2023-10-09T17:51:27.122616+02:00"
}
]
}
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:
-
Use parse_json() to parse
$raw_event
into fields. -
Create and populate any additional custom fields.
-
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-2023 20:11:15.187 client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)",
"event_timestamp": "2023-05-16T20:11: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.
Output format directives
The following directives define how the module formats the log records it sends to Google Chronicle.
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 required when ChronicleMode is set to |
|
This directive specifies the Google Chronicle API endpoint. The accepted values are:
|
|
The output data from each NXLog module is mapped to the Chronicle UDM format using a custom schema mapping. Use this directive to specify the name of a different schema file and override the default mapping. This directive only applies when ChronicleMode is set to |
|
Specify the path to the directory containing the custom schema files defined by the ChronicleSchema and SchemaMap directives. The path can be relative to the configuration directory. This directive only applies when ChronicleMode is set to |
|
Use this directive to map the data schema dynamically.
|
HTTP(S) directives
The following directives are for configuring HTTP(S) connection settings.
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). |
|
This optional directive can be specified multiple times to add custom headers to each HTTP request. |
|
This optional directive can be used to enable HTTP compression for outgoing HTTP messages.
The possible values are |
|
HTTP basic authorization username. You must also set the HTTPBasicAuthPassword directive to use HTTP authorization. |
|
HTTP basic authorization password. You must also set the HTTPBasicAuthUser directive to use HTTP authorization. |
|
This boolean directive specifies whether the connection should be allowed with an expired certificate.
If set to |
|
This boolean directive specifies that the connection should be allowed without certificate verification.
If set to |
|
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:
For example, if the certificate hash is 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 |
|
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). |
|
This specifies the path of the certificate file that will be presented to the remote client during the HTTPS handshake. |
|
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. |
|
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 |
|
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
This directive specifies a regional endpoint. Supported values are: |
|||||
Specifies the Google Chronicle Ingestion API version. The supported values are API v1 requires a ChronicleKey. API v2 requires a CredentialsFile and CustomerId. |
|||||
This directive specifies a Chronicle Ingestion API access key required for API v1. Chronicle responds with HTTP error 403 if this key is not valid. This directive is only required for API v1. See the ChronicleVersion directive for more information. |
|||||
This directive specifies the path to the private key file of the Google Developer Service Account required for authenticating with Google Chronicle API v2. Chronicle responds with HTTP error 403 if this key is not valid. See Configuring a Google Cloud service account for more information. This directive is only required for API v2. See the ChronicleVersion directive for more information. |
|||||
This directive specifies the unique identifier (UUID) corresponding to your Chronicle instance. The ID is provided by your Chronicle representative. The Ingestion API responds with HTTP error 400 or 403 if the UUID is not valid. This directive is optional for API v1 and required for API v2. See the ChronicleVersion directive for more information. |
|||||
Optional directive for specifying the Chronicle Ingestion API endpoint. Alternatively, use the optional ChronicleRegion, ChronicleVersion, ChronicleMode,
and ChronicleKey directives to use the default endpoint:
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.
|
Examples
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.
# Google Chronicle API key, required.
define API_KEY <YOUR_API_KEY>
<Extension syslog>
Module xm_syslog
</Extension>
<Output chronicle>
Module om_chronicle
ChronicleKey %API_KEY%
# Unstructured events
ChronicleMode unstructured
# Identifies the type of logs in the batch.
LogType BIND_DNS
<Exec>
$Message = $raw_event;
to_syslog_bsd();
</Exec>
</Output>
09-Oct-2023 17:33:15.187 queries: info: client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)
09-Oct-2023 17:34:16.120 queries: info: client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)
09-Oct-2023 17:35:17.165 queries: info: client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)
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 and corresponds to the $EventReceivedTime core field.
{
"log_type": "BIND_DNS",
"entries": [
{
"log_text": "<13>Oct 9 17:33:15 SERVER-1 09-Oct-2023 17:33:15.187 queries: info: client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)",
"ts_rfc3339": "2023-10-09T17:51:27.122616+02:00"
},
{
"log_text": "<13>Oct 9 17:34:16 SERVER-1 09-Oct-2023 17:34:16.120 queries: info: client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)",
"ts_rfc3339": "2023-10-09T17:51:27.126157+02:00"
},
{
"log_text": "<13>Oct 9 17:35:17 SERVER-1 09-Oct-2023 17:35:17.165 queries: info: client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)",
"ts_rfc3339": "2023-10-09T17:51:27.126176+02:00"
}
]
}
This configuration collects logs from a BIND 9 DNS server and forwards them to Chronicle in UDM format. It parses log records into structured data with a regular expression and uses a custom ChronicleSchema file in the same folder as the NXLog configuration.
# Google Chronicle API key, required.
define API_KEY <YOUR_API_KEY>
<Input dns>
Module im_file
File '/var/log/bind.log'
<Exec>
if $raw_event =~ /(?x)^(?<EventTime>\S+\s\S+)\s(?<category>.*):\s
(?<severity>.*):\s.*\s(?<source>.*)\#
(?<port>\d+):\s+(?<message>.+)$/
{
$EventTime = parsedate($EventTime);
}
</Exec>
</Input>
<Output chronicle_udm>
Module om_chronicle
ChronicleKey %API_KEY%
ChronicleMode structured
ChronicleSchema 'bind_dns.json'
</Output>
{
"metadata": {
"event_type": "NETWORK_DNS",
"event_timestamp": "$EventTime",
"ingested_timestamp": "$EventReceivedTime",
"description": "$message",
"product_name": "BIND 9",
"vendor_name": "ISC",
"product_event_type": "$category",
"severity_details": "$severity",
"ingestion_labels": [
{
"key": "source_module_name",
"value": "$SourceModuleName"
},
{
"key": "source_module_type",
"value": "$SourceModuleType"
}
]
},
"src": {
"ip": "$source",
"port": "$port"
},
"principal": {
"hostname": "$Hostname"
}
}
09-Oct-2023 17:33:15.187 queries: info: client 10.120.20.20#4238: query: example.com IN A + (100.90.80.102)
The following is the JSON-formatted log record that will be sent to Google Chronicle.
{
"events": [
{
"metadata": {
"description": "query: example.com IN A + (100.90.80.102)",
"event_timestamp": "2023-10-09T17:35:17.165000+02:00",
"event_type": "NETWORK_DNS",
"ingested_timestamp": "2023-10-09T17:39:17.901029+02:00",
"ingestion_labels": [
{
"key": "source_module_name",
"value": "dns"
},
{
"key": "source_module_type",
"value": "im_file"
}
],
"product_event_type": "queries",
"product_name": "BIND 9",
"severity_details": "info",
"vendor_name": "ISC"
},
"principal": {
"hostname": "SERVER-1"
},
"src": {
"ip": "10.120.20.20",
"port": "4238"
}
}
]
}
This configuration sends logs to Chronicle in UDM format.
The output instance implements schema-selection logic based on the $EventType
field.
It sets the SchemaDir to a folder relative to the NXLog configuration file and uses the SchemaMap directive and set_schema() procedure to set the UDM schema dynamically.
# Google Chronicle API key, required.
define API_KEY <YOUR_API_KEY>
<Output chronicle_udm>
Module om_chronicle
ChronicleKey %API_KEY%
ChronicleMode structured
SchemaDir 'chronicle-schemas'
<SchemaMap>
copy file-copy.json
delete file-delete.json
spawn process-create.json
default default.json
</SchemaMap>
<Exec>
if ($EventType == "File copied") {
set_schema("copy");
}
else if ($EventType == "File deleted") {
set_schema("delete");
}
else if ($EventType == "Process created") {
set_schema("spawn");
}
else {
set_schema("default");
}
</Exec>
</Output>
This configuration collects logs from a BIND 9 DNS server and forwards them to Chronicle in unstructured format. Sending logs to Chronicle Ingestion API v2 requires the following directives:
# Chronicle UUID, required.
define CUSTOMER_ID <YOUR_CHRONICLE_UUID>
<Extension syslog>
Module xm_syslog
</Extension>
<Output chronicle_v2>
Module om_chronicle
ChronicleVersion v2
CustomerId %CUSTOMER_ID%
# Google Service Account credentias file, required.
CredentialsFile '/opt/nxlog/etc/credentials.json'
# Unstructured events
ChronicleMode unstructured
# Identifies the type of logs in the batch.
LogType BIND_DNS
<Exec>
$Message = $raw_event;
to_syslog_bsd();
</Exec>
</Output>