Google Cloud Dataproc Sink Connector for Confluent Cloud

Note

If you are installing the connector locally for Confluent Platform, see Google Cloud Dataproc Sink Connector for Confluent Platform.

The Kafka Connect Google Cloud Dataproc Sink Connector for Confluent Cloud integrates Apache Kafka® with managed HDFS instances in Google Cloud Dataproc. The connector periodically polls data from Kafka and writes this data to HDFS. The connector supports Avro, JSON Schema, Protobuf, or JSON (schemaless) input data formats and Avro, JSON, and String output formats.

The Kafka Connect Google Cloud Dataproc sink connector integrates with Hive. When it is enabled, the connector automatically creates an external Hive partitioned table for each Kafka topic and updates the table according to the available data in HDFS.

Important

After this connector moves from Preview to General Availability (GA), Confluent Cloud Enterprise customers must have a Confluent Cloud annual commitment to use this connector. Contact your Confluent Account Executive to learn more and to update your subscription, if necessary.

Features

The Google Cloud Dataproc sink connector provides the following features:

  • Exactly Once Delivery: The connector uses a write ahead log to ensure each record exports to HDFS exactly once. Also, the connector manages the offsets commit by encoding the Kafka offset information into the file so that the connector can start from the last committed offsets in case of failures and task restarts.

  • Data formats: The connector supports Avro, JSON Schema, Protobuf, or JSON (schemaless) input data formats and Avro, JSON, and String output formats. Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON Schema, or Protobuf).

  • Hive Integration: The connector supports Hive integration. When it is enabled, the connector automatically creates a Hive external partitioned table for each topic exported to HDFS. input.data.format should be AVRO

  • Time-Based Partitioner: The connector supports a daily and hourly partitioner.

  • Seamless Dataproc Integration: The only connection requirements are the Google Cloud Platform credentials and the Dataproc cluster name and project. No need to get the HDFS URL or adjust a Hadoop configuration.

  • High Availability (HA) Cluster Support: No additional configuration is required to connect to a multi-master HA cluster.

  • Flush size: flush.size defaults to 1000. The default value can be increased if needed. The default value can be lowered if you are running a Dedicated Confluent Cloud cluster.

    The following scenarios describe a couple of ways records may be flushed to storage:

    • You use the default setting of 1000 and your topic has six partitions. Files start to be created in storage after more than 1000 records exist in each partition.
    • You use the default setting of 1000 and the partitioner is set to Hourly. 500 records arrive at one partition from 2:00pm to 3:00pm. At 3:00pm, an additional 5 records arrive at the partition. You will see 500 records in storage at 3:00pm.

Refer to Cloud connector limitations for additional information.

Caution

Preview connectors are not currently supported and are not recommended for production use.

Quick Start

Use this quick start to get up and running with the Confluent Cloud Google Cloud Dataproc sink connector. The quick start provides the basics of selecting the connector and configuring it to stream events to HDFS.

Prerequisites
  • Kafka cluster credentials. You can use one of the following ways to get credentials:
    • Create a Confluent Cloud API key and secret. To create a key and secret, go to Kafka API keys in your cluster or you can autogenerate the API key and secret directly in the UI when setting up the connector.
    • Create a Confluent Cloud service account for the connector.

Using the Confluent Cloud GUI

Complete the following steps to set up and run the connector using the Confluent Cloud GUI.

Step 1: Launch your Confluent Cloud cluster.

See the Quick Start for Apache Kafka using Confluent Cloud for installation instructions.

Step 2: Add a connector.

Click Connectors. If you already have connectors in your cluster, click Add connector.

Step 3: Select your connector.

Click the Google Cloud Dataproc Sink connector icon.

Google Cloud Dataproc Sink Connector Icon

Step 4: Enter the cluster details.

Note

  • Make sure you have all your prerequisites completed.
  • An asterisk ( * ) designates a required entry.

Complete the following and click Continue.

  1. Select an Input message format (data coming from the Kafka topic): AVRO, JSON_SR (JSON Schema), PROTOBUF, or JSON (schemaless). A valid schema must be available in Schema Registry to use a schema-based message format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).

    Note

    Input format JSON to output format AVRO does not work for the preview connector.

  2. Enter a Connector Name.

  3. Enter your Kafka Cluster credentials. The credentials are either the API key and secret or the service account API key and secret.

Step 5: Enter the destination details.

Important

Your GCP credentials are validated here. Make sure you enter these correctly.

  1. Select the format for messages coming from the Kafka topic. Note that input format JSON to output format AVRO does not work for the preview connector. A valid schema must be available in Confluent Cloud Schema Registry to use a schema-based message format, like Avro.

  2. Upload your GCP credentials JSON file.

  3. Enter your Dataproc project ID and cluster name.

  4. Under HDFS details, enter the topics directory (optional) and the top-level HDFS directory where write-ahead logs are stored.

  5. Select an Output message format (data coming from the connector): AVRO, JSON, or STRING. A valid schema must be available in Schema Registry to use a schema-based message format (for example, Avro).

  6. Under Hive, select whether you want to use Hive integration and then add the details for your Hive configuration.

  7. Under Organize my data, enter the following properties:

    • Time interval: Select the time-based partitioning interval you want to use.

    • Flush size. This value defaults to 1000. The default value can be increased or lowered if needed.

      The following scenarios describe a couple of ways records may be flushed to storage:

      • You use the default setting of 1000 and your topic has six partitions. Files start to be created in storage after more than 1000 records exist in each partition.
      • You use the default setting of 1000 and the partitioner is set to Hourly. 500 records arrive at one partition from 2:00pm to 3:00pm. At 3:00pm, an additional 5 records arrive at the partition. You will see 500 records in storage at 3:00pm.

  8. Enter the maximum number of tasks the connector can use. Refer to Confluent Cloud connector limitations for additional information.

Configuration properties that are not shown in the Confluent Cloud UI use the default values. For default values and property definitions, see Google Cloud Dataproc Sink Connector Configuration Properties.

Step 6: Launch the connector.

Verify the following and click Launch.

Launch the connector

Step 7: Check the connector status.

The status for the connector should go from Provisioning to Running.

Step 8: Check the Dataproc cluster.

Go to your Dataproc cluster and make sure the topic is being populated with records.

Tip

When you launch a connector, a Dead Letter Queue topic is automatically created. See Confluent Cloud Dead Letter Queue for details.

For additional information about this connector, see Google Cloud Dataproc Sink Connector for Confluent Platform. Note that not all Confluent Platform connector features are provided in the Confluent Cloud connector.

See also

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL example. This example also shows how to use Confluent Cloud CLI to manage your resources in Confluent Cloud.

../../_images/topology.png

Using the Confluent Cloud CLI

Complete the following steps to set up and run the connector using the Confluent Cloud CLI.

Note

Make sure you have all your prerequisites completed.

Step 1: List the available connectors.

Enter the following command to list available connectors:

ccloud connector-catalog list

Step 2: Show the required connector configuration properties.

Enter the following command to show the required connector properties:

ccloud connector-catalog describe <connector-catalog-name>

For example:

ccloud connector-catalog describe DataprocSink

Example output:

Following are the required configs:
connector.class: DataprocSink
name
kafka.api.key
kafka.api.secret
topics
input.data.format
gcp.dataproc.credentials.json
gcp.dataproc.projectId
gcp.dataproc.cluster
gcp.dataproc.namenode
logs.dir
output.data.format
time.interval
tasks.max

Step 3: Create the connector configuration file.

Create a JSON file that contains the connector configuration properties. The following example shows required and optional connector properties.

{
  "connector.class": "DataprocSink",
  "name": "dataproc-test",
  "kafka.api.key": "<my-kafka-api-key>",
  "kafka.api.secret": "<my-kafka-api-secret>",
  "topics": "<topic-name>",
  "input.data.format": "AVRO",
  "gcp.dataproc.credentials.json": "<credentials-json-file-contents>",
  "gcp.dataproc.projectId": "<my-dataproc-project-ID",
  "gcp.dataproc.cluster": "<my-dataproc-cluster-name>",
  "gcp.dataproc.namenode": "<IP-address-of-the-namenode>",
  "logs.dir": "<HDFS-logs-directory>",
  "output.data.format": "AVRO",
  "flush.size": "1000",
  "time.interval": "HOURLY",
  "tasks.max": "1"
}

Note the following property definitions:

  • "name": Sets a name for your new connector.

  • "connector.class": Identifies the connector plugin name.

  • "topics": Identifies the topic name or a comma-separated list of topic names.

  • "input.data.format": Sets the input message format (data coming from the Kafka topic). Valid entries are AVRO, JSON_SR, PROTOBUF, or JSON. You must have Confluent Cloud Schema Registry configured if using a schema-based message format (for example, Avro, JSON_SR (JSON Schema), or Protobuf).

    Note

    Input format JSON to output format AVRO does not work for the preview connector.

  • "gcp.dataproc.credentials.json": This contains the contents of the downloaded JSON file. See Formatting GCP credentials for details about how to format and use the contents of the downloaded credentials file.

  • "gcp.dataproc.namenode": For VPC-peered environments, this is the internal IP address of the HDFS NameNode (GCP Dataproc master node). For non-VPC-peered environments, this the FQDN resolving to the public IP address or the public IP address of the NameNode (for example: cluster1-m.confluentinc.com). For non-VPC-peered environment configuration details, see Configuring a non-VPC peering environment.

  • "logs.dir": This is the the top-level HDFS directory where write-ahead logs are stored.

  • "output.data.format": Sets the output message format. Valid entries are AVRO, JSON, or STRING. You must have Confluent Cloud Schema Registry configured if using a schema-based output message format (for example, Avro).

  • (Optional) flush.size: This value defaults to 1000. The default value can be increased or lowered if needed.

    The following scenarios describe a couple of ways records may be flushed to storage:

    • You use the default setting of 1000 and your topic has six partitions. Files start to be created in storage after more than 1000 records exist in each partition.
    • You use the default setting of 1000 and the partitioner is set to Hourly. 500 records arrive at one partition from 2:00pm to 3:00pm. At 3:00pm, an additional 5 records arrive at the partition. You will see 500 records in storage at 3:00pm.

  • "time.interval": Sets how your messages are grouped. Valid entries are DAILY or HOURLY.

Configuration properties that are not listed use the default values. For default values and property definitions, see Google Cloud Dataproc Sink Connector Configuration Properties.

Formatting GCP credentials

The contents of the downloaded credentials file must be converted to string format before it can be used in the connector configuration.

  1. Convert the JSON file contents into string format. You can use an online converter tool to do this. For example: JSON to String Online Converter.

  2. Add the escape character \ before all \n entries in the Private Key section so that each section begins with \\n (see the highlighted lines below). The example below has been formatted so that the \\n entries are easier to see. Most of the credentials key has been omitted.

    Tip

    A script is available that converts the credentials to a string and also adds additional \ escape characters where needed. See Stringify GCP Credentials.

      {
          "connector.class": "DataprocSink",
          "name": "dataproc-sink",
          "kafka.api.key": "<my-kafka-api-key>",
          "kafka.api.secret": "<my-kafka-api-secret>",
          "topics": "<topic-name>",
          "data.format": "AVRO",
          "gcp.dataproc.credentials.json" : "{\"type\":\"service_account\",\"project_id\":\"connect-
          1234567\",\"private_key_id\":\"omitted\",
          \"private_key\":\"-----BEGIN PRIVATE KEY-----
          \\nMIIEvAIBADANBgkqhkiG9w0BA
          \\n6MhBA9TIXB4dPiYYNOYwbfy0Lki8zGn7T6wovGS5pzsIh
          \\nOAQ8oRolFp\rdwc2cC5wyZ2+E+bhwn
          \\nPdCTW+oZoodY\\nOGB18cCKn5mJRzpiYsb5eGv2fN\/J
          \\n...rest of key omitted...
          \\n-----END PRIVATE KEY-----\\n\",
          \"client_email\":\"pub-sub@connect-123456789.iam.gserviceaccount.com\",
          \"client_id\":\"123456789\",\"auth_uri\":\"https:\/\/accounts.google.com\/o\/oauth2\/
          auth\",\"token_uri\":\"https:\/\/oauth2.googleapis.com\/
          token\",\"auth_provider_x509_cert_url\":\"https:\/\/
          www.googleapis.com\/oauth2\/v1\/
          certs\",\"client_x509_cert_url\":\"https:\/\/www.googleapis.com\/
          robot\/v1\/metadata\/x509\/pub-sub%40connect-
          123456789.iam.gserviceaccount.com\"}",
          "gcp.dataproc.projectId": "<my-dataproc-project-ID",
          "gcp.dataproc.region": "<gcp-region>",
          "gcp.dataproc.cluster": "<my-dataproc-cluster-name>",
          "logs.dir": "<HDFS-logs-directory>",
          "flush.size": "1000",
          "time.interval": "HOURLY",
          "tasks.max": "1"
      }
    
  3. Add all the converted string content to the "gcp.dataproc.credentials.json" section of your configuration file as shown in the example above.

Step 4: Load the configuration file and create the connector.

Enter the following command to load the configuration and start the connector:

ccloud connector create --config <file-name>.json

For example:

ccloud connector create --config dataproc-sink-config.json

Example output:

Created connector dataproc-sink lcc-ix4dl

Step 5: Check the connector status.

Enter the following command to check the connector status:

ccloud connector list

Example output:

ID          |       Name      | Status  | Type
+-----------+-----------------+---------+------+
lcc-ix4dl   | dataproc-sink   | RUNNING | sink

Step 6: Check the Dataproc cluster.

Go to your Dataproc cluster and make sure the topic is being populated with records.

Tip

When you launch a connector, a Dead Letter Queue topic is automatically created. See Confluent Cloud Dead Letter Queue for details.

For additional information about this connector, see Google Cloud Dataproc Sink Connector for Confluent Platform. Note that not all Confluent Platform connector features are provided in the Confluent Cloud connector.

Next Steps

See also

For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud ksqlDB, see the Cloud ETL example. This example also shows how to use Confluent Cloud CLI to manage your resources in Confluent Cloud.

../../_images/topology.png