Google Cloud Pub/Sub (om_googlepubsub)
Google Cloud Pub/Sub is a service that allows event producers to deliver events to subscribers asynchronously. It is commonly used for data streaming, real-time event distribution, or as a message queue for parallel workflows.
This module uses the Google Pub/Sub REST API to publish logs to a Google Pub/Sub topic.
om_googlepubsub trims messages containing a NULL byte (\x00), discarding all subsequent data.
Ensure that messages do not contain NULL byte characters at the event source, or contact NXLog if this is not possible.
|
| To examine the supported platforms, see the list of installation packages. |
Configuring a Google Cloud service account
om_googlepubsub requires a Google Cloud service account and a corresponding private key file in JSON format to connect to the Google Cloud Pub/Sub API. Follow these instructions to create a new service account and download its private key file for an existing project.
-
Log in to your Google Cloud account and switch to the project you want to configure.
-
From the navigation menu, click IAM & Admin > Service Accounts.
-
Click CREATE SERVICE ACCOUNT.
-
Enter a service account name and description and click CREATE AND CONTINUE.
-
Select the Owner role from the Role drop-down and click DONE.
-
Click on the newly created account on the Service accounts page to open its configuration page.
-
Click the KEYS tab, expand the ADD KEY drop-down and select Create new key.
-
Select JSON for the key type and click CREATE to download the private key. Save the private key file to a location accessible by NXLog Agent. This file is required for the NXLog Agent configuration.
Configuration
The om_googlepubsub module accepts the following directives in addition to the common module directives. The CredentialsFile and Topic directives are required.
Required directives
The following directives are required for the module to start.
This mandatory directive specifies the path to the private key file of the service account required for authenticating with the Google Pub/Sub. See Configuring a Google Cloud service account for more information. |
|
This mandatory directive specifies the name of the topic that will publish the messages.
The format is |
HTTPS directives
The following directives configure secure data transfer via HTTPS.
Set this directive to |
|
Set this directive to |
|
Set this directive to the path of a directory containing Certificate Authority (CA) certificates.
The module uses these certificates to verify the certificate presented by the remote host.
Name the certificate files using the OpenSSL hashed format: the hash of the certificate followed by
For example, if the certificate hash is To trust a remote host’s self-signed certificate, include a copy of it in this directory. If this directive isn’t specified, NXLog Agent falls back to the default operating system root certificate store.
Unix-like operating systems commonly store root certificates in In addition, Microsoft’s PKI repository contains root certificates for Microsoft services. |
|
Set this directive to the path of the Certificate Authority (CA) certificate used to verify the certificate presented by the remote host. To trust a remote host’s self-signed certificate, specify the remote host’s certificate itself. For certificates signed by an intermediate CA, the specified certificate must contain the complete certificate chain (certificate bundle). |
|
Set this directive to the path of the certificate file to present to the remote host during the HTTPS handshake. |
|
Set this directive to the path of the private key file corresponding to the certificate specified by HTTPSCertFile. |
Optional directives
A list of key-value pairs for providing event metadata.
|
|||
Set this directive to a custom header to add to each HTTP request. Specify this directive multiple times to add more than one header. |
|||
Set this directive to enable HTTP compression for outgoing HTTP messages.
The accepted values are Some HTTP servers may not accept compressed HTTP requests.
If the server doesn’t support the specified compression method, it may return |
|||
Set this directive to the HTTP basic authentication password. This directive requires you to also set the HTTPBasicAuthUser directive to use HTTP authentication. |
|||
Set this directive to the HTTP basic authentication username. If the HTTPBasicAuthPassword directive is not set, the module attempts HTTP Basic authentication using an empty password. |
|||
Set this directive to the maximum request size, in bytes. The default is 64 MB. |
|||
Set this directive to route outgoing requests through an HTTP or SOCKS proxy host.
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 double with every attempt. In the latter case, when the system decides that the reconnection is successful, the reconnect interval is immediately reset to 1 sec.
|
|||
This optional directive defines the behavior when the connection with the remote host is lost.
When set to |
|||
Number of allowed parallel HTTP connections. The default is 1. |
|||
Optional directive for specifying a region-specific URL.
The default is |
Examples
This configuration uses the om_googlepubsub output module to publish logs to the test topic of the Google Cloud project myproject.
<Output google_pubsub>
Module om_googlepubsub
CredentialsFile /path/to/credentials.json (1)
Topic projects/myproject-343509/topics/test
<Attributes> (2)
zone us-central
</Attributes>
</Output>
| 1 | Credentials file for authenticating with the Google Pub/Sub. See Configuring a Google Cloud service account for more information. |
| 2 | List of labels defined as key-value pairs to attach to the event. |