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.
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 |
HTTP(S) directives
The following directives are for configuring HTTP(S) connection settings.
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 password.
|
|||
HTTP basic authorization username.
|
|||
Specifies if the connection should be allowed with an expired certificate.
If set to |
|||
Specifies if the connection should be allowed without certificate verification.
If set to |
|||
The path to a directory containing certificate authority (CA) certificates. These certificates will be used to verify the certificate presented by the remote host. 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 host’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 In addition, Microsoft’s PKI repository contains root certificates for Microsoft services. |
|||
The path of the certificate authority (CA) certificate that will be used to verify the certificate presented by the remote host. A remote host’s self-signed certificate (which is not signed by a CA) can be trusted by specifying the remote host certificate itself. In case of certificates signed by an intermediate CA, the certificate specified must contain the complete certificate chain (certificate bundle). |
|||
The path of the certificate file that will be presented to the remote host during the HTTPS handshake. |
|||
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. |
|||
Maximum size of the request in bytes. The default is 64 MB. |
|||
This optional directive is used to specify the protocol, IP address (or hostname) and port number of the HTTP or SOCKS proxy host 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 double with 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.
|
|||
This optional directive defines the behavior when the connection with the remote host is lost.
When set to |
Optional directives
A list of key-value pairs for providing event metadata.
|
|
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. |