NXLog Legacy Documentation

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 installer packages in the Available Modules chapter.

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.

  1. Log in to your Google Cloud account and switch to the project you want to configure.

  2. From the navigation menu, click on IAM & Admin > Service Accounts.

    IAM & Admin menu
  3. Click CREATE SERVICE ACCOUNT.

  4. Enter a service account name and description and click CREATE AND CONTINUE.

    Create service account
  5. Select the Owner role from the Role drop-down and click DONE.

    Service account role
  6. Click on the newly created account on the Service accounts page to open its configuration page.

  7. Click the KEYS tab, expand the ADD KEY drop-down and select Create new key.

    Create new service key
  8. 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. This file is required for the NXLog configuration.

    New service key type

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.

CredentialsFile

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.

Topic

This mandatory directive specifies the name of the topic which will publish the messages. The format is projects/{project}/topics/{topic}.

Optional directives

Attributes

A list of key-value pairs for providing event metadata.

<Attributes>
    zone    us-central
</Attributes>

Connections

Number of allowed parallel HTTP connections. The default is 1.

OutputRequestSize

Maximum size of the request in bytes. The default is 65 KB.

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.

URL

Optional directive for specifying a region-specific URL. The default is https://pubsub.googleapis.com.

Examples

Example 1. Forwarding logs to Google Pub/Sub

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.