Google Cloud Storage Source Connector for Confluent Cloud
The fully-managed Google Cloud Storage (GCS) Source connector for Confluent Cloud can read data from any type of file naming convention listed under a GCS bucket (that is, the filenames in the bucket don’t have to be in a specific format). The connector can read file data in any of the supported formats (for example, JSON, Avro, and Byte Array).
Confluent Cloud is available through Google Cloud Marketplace or directly from Confluent.
Note
This is a Quick Start for the fully-managed cloud connector. If you are installing the connector locally for Confluent Platform, see Google Cloud Storage (GCS) Source Connector for Confluent Platform.
Features
The GCS Source connector provides the following features:
At least once delivery: The connector guarantees that records are delivered at least once.
Provider integration support: The connector supports Google Cloud’s native identity authorization using Confluent Provider Integration. For more information about provider integration setup, see the connector authentication.
Supports multiple tasks: The connector supports running one or more tasks.
Offset management capabilities: Supports offset management. For more information, see Manage custom offsets.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect Usage Examples section.
Refer to Confluent Cloud connector limitations for additional information.
IAM Policy for GCS
The following permissions are required for the GCS Source connector:
storage.buckets.getstorage.objects.getstorage.objects.list
For more information, see IAM permissions for Cloud Storage.
You may also grant a Service Account the following roles on the bucket:
Storage Object Viewer
Storage Legacy Bucket Reader
Manage custom offsets
You can manage the offsets for this connector. Offsets provide information on the point in the system from which the connector is accessing data. For more information, see Manage Offsets for Fully-Managed Connectors in Confluent Cloud.
To manage offsets:
Manage offsets using Confluent Cloud APIs. For more information, see Cluster API reference.
To get the current offset, make a GET request that specifies the environment, Kafka cluster, and connector name.
GET /connect/v1/environments/{environment_id}/clusters/{kafka_cluster_id}/connectors/{connector_name}/offsets
Host: https://api.confluent.cloud
Response:
Successful calls return HTTP 200 with a JSON payload that describes the offset.
{
"id": "lcc-example123",
"name": "{connector_name}",
"offsets": [
{
"partition": {
"taskId": "lcc-example123-0-in_progress"
},
"offset": {
"earliestIncomplete": "2023-08-03T10:24:25Z",
"completedFiles": "[{\"filePath\":\"topics/abc_0/partition=0/abc_0+0+00000.json\",\"creationTime\":\"2023-08-03T10:24:25Z\"},{\"filePath\":\"topics/abc_1/partition=0/abc_1+0+00000.json\",\"creationTime\":\"2023-08-03T10:34:56Z\"},{\"filePath\":\"topics/abc_3/partition=0/abc_3+0+00000.json\",\"creationTime\":\"2023-08-03T10:48:28Z\"}]",
"recordNum": "98"
}
}
{
"partition": {
"taskId": "lcc-example123-1"
},
"offset": {
"earliestIncomplete": "2023-08-03T10:24:25Z",
"completedFiles": "[{\"filePath\":\"topics/babc_4/partition=0/babc_4+0+00000.json\",\"creationTime\":\"2023-08-03T10:33:04Z\"},{\"filePath\":\"topics/abc_2/partition=0/abc_2+0+00000.json\",\"creationTime\":\"2023-08-03T10:46:06Z\"},{\"filePath\":\"topics/weird/partition=0/weird+0+00000 copy.json\",\"creationTime\":\"2023-08-03T10:51:09Z\"}]",
"recordNum": "99"
}
}
{
"partition": {
"taskId": "lcc-example123-0"
},
"offset": {
"earliestIncomplete": "2023-08-03T10:24:25Z",
"completedFiles": "[{\"filePath\":\"topics/abc_0/partition=0/abc_0+0+00000.json\",\"creationTime\":\"2023-08-03T10:24:25Z\"},{\"filePath\":\"topics/abc_1/partition=0/abc_1+0+00000.json\",\"creationTime\":\"2023-08-03T10:34:56Z\"},{\"filePath\":\"topics/abc_3/partition=0/abc_3+0+00000.json\",\"creationTime\":\"2023-08-03T10:48:28Z\"},{\"filePath\":\"topics/abc_5/partition=0/abc_5+0+00000.json\",\"creationTime\":\"2023-08-03T10:59:06Z\"}]",
"recordNum": "99"
}
}
{
"partition": {
"taskId": "lcc-example123-1-in_progress"
},
"offset": {
"earliestIncomplete": "2023-08-03T10:24:25Z",
"completedFiles": "[{\"filePath\":\"topics/babc_4/partition=0/babc_4+0+00000.json\",\"creationTime\":\"2023-08-03T10:33:04Z\"},{\"filePath\":\"topics/abc_2/partition=0/abc_2+0+00000.json\",\"creationTime\":\"2023-08-03T10:46:06Z\"}]",
"recordNum": "98"
}
}
],
"metadata": {
"observed_at": "2024-03-28T17:57:48.139635200Z"
}
}
Responses include the following information:
The position of latest offset.
The observed time of the offset in the metadata portion of the payload. The
observed_attime indicates a snapshot in time for when the API retrieved the offset. A running connector is always updating its offsets. Useobserved_atto get a sense for the gap between real time and the time at which the request was made. By default, offsets are observed every minute. CallingGETrepeatedly will fetch more recently observed offsets.Information about the connector.
You can approach offset updates in two ways:
Modify the
earliestIncompletetime to reset the offsets so that next scan will source the files withcreationTimeequal to or after the newearliestIncomplete.If you use this approach, consider this:
If
earliestIncompleteis set to a later time, the connector starts sourcing the files withcreationTimeequal to or after theearliestIncompleteand skips records.If
earliestIncompleteis set to an earlier time, the connector might produce duplicate records because it starts sourcing every record from files with acreationTimeequal to or after the earlier time.
If you want to skip processing a file or files, add the files to
completedFiles.
To update the offset, make a POST request that specifies the environment, Kafka cluster, and connector name. Include a JSON payload that specifies new offset and a patch type.
POST /connect/v1/environments/{environment_id}/clusters/{kafka_cluster_id}/connectors/{connector_name}/offsets/request
Host: https://api.confluent.cloud
{
"type": "PATCH",
"offsets": [
{
"partition": {
"taskId": "lcc-devc3m1zkj-0"
},
"offset": {
"completedFiles": "[{\"filePath\":\"source/file_0\",\"creationTime\":\"2024-03-06T17:30:28.391Z\"},{\"filePath\":\"source/file_7\",\"creationTime\":\"2024-03-06T17:30:28.395Z\"},{\"filePath\":\"source/file_9\",\"creationTime\":\"2024-03-06T17:30:28.409Z\"},{\"filePath\":\"source/file_1\",\"creationTime\":\"2024-03-06T17:30:28.681Z\"},{\"filePath\":\"source/file_8\",\"creationTime\":\"2024-03-06T17:30:28.681Z\"},{\"filePath\":\"source/file_6\",\"creationTime\":\"2024-03-06T17:30:28.715Z\"},{\"filePath\":\"source/file_30\",\"creationTime\":\"2024-03-06T17:30:28.969Z\"},{\"filePath\":\"source/file_39\",\"creationTime\":\"2024-03-06T17:30:28.970Z\"},{\"filePath\":\"source/file_37\",\"creationTime\":\"2024-03-06T17:30:28.993Z\"},{\"filePath\":\"source/file_36\",\"creationTime\":\"2024-03-06T17:30:29.265Z\"},{\"filePath\":\"source/file_31\",\"creationTime\":\"2024-03-06T17:30:29.268Z\"},{\"filePath\":\"source/file_38\",\"creationTime\":\"2024-03-06T17:30:29.278Z\"},{\"filePath\":\"source/file_25\",\"creationTime\":\"2024-03-06T17:30:29.549Z\"},{\"filePath\":\"source/file_22\",\"creationTime\":\"2024-03-06T17:30:29.551Z\"},{\"filePath\":\"source/file_13\",\"creationTime\":\"2024-03-06T17:30:29.552Z\"},{\"filePath\":\"source/file_47\",\"creationTime\":\"2024-03-06T17:30:30.015Z\"},{\"filePath\":\"source/file_14\",\"creationTime\":\"2024-03-06T17:30:30.020Z\"},{\"filePath\":\"source/file_40\",\"creationTime\":\"2024-03-06T17:30:30.028Z\"},{\"filePath\":\"source/file_15\",\"creationTime\":\"2024-03-06T17:30:30.305Z\"}]",
"earliestIncomplete": "2024-03-06T17:30:28.391Z",
"recordNum": "0"
}
}
]
}
Considerations:
You can only make one offset change at a time for a given connector.
This is an asynchronous request. To check the status of this request, you must use the check offset status API. For more information, see Get the status of an offset request.
For source connectors, the connector attempts to read from the position defined by the requested offsets.
Response:
Successful calls return HTTP 202 Accepted with a JSON payload that describes the offset.
{
"id": "lcc-example123",
"name": "{connector_name}",
"offsets": [
{
"partition": {
"taskId": "lcc-example123-0"
},
"offset": {
"completedFiles": "[{\"filePath\":\"source/file_0\",\"creationTime\":\"2024-03-06T17:30:28.391Z\"},{\"filePath\":\"source/file_7\",\"creationTime\":\"2024-03-06T17:30:28.395Z\"},{\"filePath\":\"source/file_9\",\"creationTime\":\"2024-03-06T17:30:28.409Z\"},{\"filePath\":\"source/file_1\",\"creationTime\":\"2024-03-06T17:30:28.681Z\"},{\"filePath\":\"source/file_8\",\"creationTime\":\"2024-03-06T17:30:28.681Z\"},{\"filePath\":\"source/file_6\",\"creationTime\":\"2024-03-06T17:30:28.715Z\"},{\"filePath\":\"source/file_30\",\"creationTime\":\"2024-03-06T17:30:28.969Z\"},{\"filePath\":\"source/file_39\",\"creationTime\":\"2024-03-06T17:30:28.970Z\"},{\"filePath\":\"source/file_37\",\"creationTime\":\"2024-03-06T17:30:28.993Z\"},{\"filePath\":\"source/file_36\",\"creationTime\":\"2024-03-06T17:30:29.265Z\"},{\"filePath\":\"source/file_31\",\"creationTime\":\"2024-03-06T17:30:29.268Z\"},{\"filePath\":\"source/file_38\",\"creationTime\":\"2024-03-06T17:30:29.278Z\"},{\"filePath\":\"source/file_25\",\"creationTime\":\"2024-03-06T17:30:29.549Z\"},{\"filePath\":\"source/file_22\",\"creationTime\":\"2024-03-06T17:30:29.551Z\"},{\"filePath\":\"source/file_13\",\"creationTime\":\"2024-03-06T17:30:29.552Z\"},{\"filePath\":\"source/file_47\",\"creationTime\":\"2024-03-06T17:30:30.015Z\"},{\"filePath\":\"source/file_14\",\"creationTime\":\"2024-03-06T17:30:30.020Z\"},{\"filePath\":\"source/file_40\",\"creationTime\":\"2024-03-06T17:30:30.028Z\"},{\"filePath\":\"source/file_15\",\"creationTime\":\"2024-03-06T17:30:30.305Z\"}]",
"earliestIncomplete": "2024-03-06T17:30:28.391Z",
"recordNum": "0"
}
}
],
"requested_at": "2024-03-28T17:58:45.606796307Z",
"type": "PATCH"
}
Responses include the following information:
The requested position of the offsets in the source.
The time of the request to update the offset.
Information about the connector.
To delete the offset, make a POST request that specifies the environment, Kafka cluster, and connector name. Include a JSON payload that specifies the delete type.
POST /connect/v1/environments/{environment_id}/clusters/{kafka_cluster_id}/connectors/{connector_name}/offsets/request
Host: https://api.confluent.cloud
{
"type": "DELETE"
}
Considerations:
Delete requests delete the offset for the provided partition and reset to the base state. A delete request is as if you created a fresh new connector.
This is an asynchronous request. To check the status of this request, you must use the check offset status API. For more information, see Get the status of an offset request.
Do not issue delete and patch requests at the same time.
For source connectors, the connector attempts to read from the position defined in the base state.
Response:
Successful calls return HTTP 202 Accepted with a JSON payload that describes the result.
{
"id": "lcc-example123",
"name": "{connector_name}",
"offsets": [],
"requested_at": "2024-03-28T17:59:45.606796307Z",
"type": "DELETE"
}
Responses include the following information:
Empty offsets.
The time of the request to delete the offset.
Information about Kafka cluster and connector.
The type of request.
To get the status of a previous offset request, make a GET request that specifies the environment, Kafka cluster, and connector name.
GET /connect/v1/environments/{environment_id}/clusters/{kafka_cluster_id}/connectors/{connector_name}/offsets/request/status
Host: https://api.confluent.cloud
Considerations:
The status endpoint always shows the status of the most recent PATCH/DELETE operation.
Response:
Successful calls return HTTP 200 with a JSON payload that describes the result. The following is an example of an applied patch.
{
"request": {
"id": "lcc-example123",
"name": "{connector_name}",
"offsets": [
{
"partition": {
"taskId": "lcc-example123-0"
},
"offset": {
"completedFiles": "[{\"filePath\":\"source/file_0\",\"creationTime\":\"2024-03-06T17:30:28.391Z\"},{\"filePath\":\"source/file_7\",\"creationTime\":\"2024-03-06T17:30:28.395Z\"},{\"filePath\":\"source/file_9\",\"creationTime\":\"2024-03-06T17:30:28.409Z\"},{\"filePath\":\"source/file_1\",\"creationTime\":\"2024-03-06T17:30:28.681Z\"},{\"filePath\":\"source/file_8\",\"creationTime\":\"2024-03-06T17:30:28.681Z\"},{\"filePath\":\"source/file_6\",\"creationTime\":\"2024-03-06T17:30:28.715Z\"},{\"filePath\":\"source/file_30\",\"creationTime\":\"2024-03-06T17:30:28.969Z\"},{\"filePath\":\"source/file_39\",\"creationTime\":\"2024-03-06T17:30:28.970Z\"},{\"filePath\":\"source/file_37\",\"creationTime\":\"2024-03-06T17:30:28.993Z\"},{\"filePath\":\"source/file_36\",\"creationTime\":\"2024-03-06T17:30:29.265Z\"},{\"filePath\":\"source/file_31\",\"creationTime\":\"2024-03-06T17:30:29.268Z\"},{\"filePath\":\"source/file_38\",\"creationTime\":\"2024-03-06T17:30:29.278Z\"},{\"filePath\":\"source/file_25\",\"creationTime\":\"2024-03-06T17:30:29.549Z\"},{\"filePath\":\"source/file_22\",\"creationTime\":\"2024-03-06T17:30:29.551Z\"},{\"filePath\":\"source/file_13\",\"creationTime\":\"2024-03-06T17:30:29.552Z\"},{\"filePath\":\"source/file_47\",\"creationTime\":\"2024-03-06T17:30:30.015Z\"},{\"filePath\":\"source/file_14\",\"creationTime\":\"2024-03-06T17:30:30.020Z\"},{\"filePath\":\"source/file_40\",\"creationTime\":\"2024-03-06T17:30:30.028Z\"},{\"filePath\":\"source/file_15\",\"creationTime\":\"2024-03-06T17:30:30.305Z\"}]",
"earliestIncomplete": "2024-03-06T17:30:28.391Z",
"recordNum": "0"
}
}
],
"requested_at": "2024-03-28T17:58:45.606796307Z",
"type": "PATCH"
},
"status": {
"phase": "APPLIED",
"message": "The Connect framework-managed offsets for this connector have been altered successfully. However, if this connector manages offsets externally, they will need to be manually altered in the system that the connector uses."
},
"previous_offsets": [
{
"partition": {
"taskId": "lcc-example123-0"
},
"offset": {
"completedFiles": "[{\"filePath\":\"source/file_31\",\"creationTime\":\"2024-03-06T17:30:29.268Z\"},{\"filePath\":\"source/file_38\",\"creationTime\":\"2024-03-06T17:30:29.278Z\"},{\"filePath\":\"source/file_25\",\"creationTime\":\"2024-03-06T17:30:29.549Z\"},{\"filePath\":\"source/file_22\",\"creationTime\":\"2024-03-06T17:30:29.551Z\"},{\"filePath\":\"source/file_13\",\"creationTime\":\"2024-03-06T17:30:29.552Z\"},{\"filePath\":\"source/file_47\",\"creationTime\":\"2024-03-06T17:30:30.015Z\"},{\"filePath\":\"source/file_14\",\"creationTime\":\"2024-03-06T17:30:30.020Z\"},{\"filePath\":\"source/file_40\",\"creationTime\":\"2024-03-06T17:30:30.028Z\"},{\"filePath\":\"source/file_15\",\"creationTime\":\"2024-03-06T17:30:30.305Z\"},{\"filePath\":\"source/file_49\",\"creationTime\":\"2024-03-06T17:30:30.313Z\"},{\"filePath\":\"source/file_12\",\"creationTime\":\"2024-03-06T17:30:30.326Z\"},{\"filePath\":\"source/file_23\",\"creationTime\":\"2024-03-06T17:30:30.600Z\"},{\"filePath\":\"source/file_24\",\"creationTime\":\"2024-03-06T17:30:30.613Z\"},{\"filePath\":\"source/file_48\",\"creationTime\":\"2024-03-06T17:30:30.639Z\"},{\"filePath\":\"source/file_46\",\"creationTime\":\"2024-03-06T17:30:30.899Z\"},{\"filePath\":\"source/file_41\",\"creationTime\":\"2024-03-06T17:30:30.926Z\"},{\"filePath\":\"source/file_3\",\"creationTime\":\"2024-03-06T17:30:30.927Z\"},{\"filePath\":\"source/file_4\",\"creationTime\":\"2024-03-06T17:30:31.198Z\"},{\"filePath\":\"source/file_5\",\"creationTime\":\"2024-03-06T17:30:31.220Z\"},{\"filePath\":\"source/file_2\",\"creationTime\":\"2024-03-06T17:30:31.225Z\"}]",
"earliestIncomplete": "2024-03-06T17:30:29.268Z",
"recordNum": "0"
}
}
],
"applied_at": "2024-03-28T17:58:48.079141883Z"
}
Responses include the following information:
The original request, including the time it was made.
The status of the request: applied, pending, or failed.
The time you issued the status request.
The previous offsets. These are the offsets that the connector last updated prior to updating the offsets. Use these to try to restore the state of your connector if a patch update causes your connector to fail or to return a connector to its previous state after rolling back.
JSON payload
The table below offers a description of the unique fields in the JSON payload for managing offsets of the object store connectors, including the following connectors:
Amazon S3 Source connector
Azure Blob Storage Source connector
Google Cloud Storage (GCS) Source connector
Field | Definition | Required/Optional |
|---|---|---|
| Represents the partition in the following format:
| Required |
| The position of the latest offset. When a connectors starts or restarts, the connector reads the files with a creation time equal to or after | Required |
| List of sourced files. | Required |
| Number of records sourced. | Required |
Quick Start
Use this quick start to get up and running with the Confluent Cloud GCS Source connector. The quick start provides the basics of selecting the connector and configuring it to get files from a GCS bucket.
- Prerequisites
Authorized access to a Confluent Cloud cluster on Amazon Web Services (AWS), Microsoft Azure (Azure), or Google Cloud.
The Confluent CLI installed and configured for the cluster. See Install the Confluent CLI.
Schema Registry must be enabled to use a Schema Registry-based format (for example, Avro, JSON_SR (JSON Schema), or Protobuf). See Schema Registry Enabled Environments for additional information.
For networking considerations, see Networking and DNS. To use a set of public egress IP addresses, see Public Egress IP Addresses for Confluent Cloud Connectors.
An IAM policy allowing bucket access. See IAM Policy for GCS.
A Google Cloud service account. You download service account credentials as a JSON file. These credentials are used when setting up the connector configuration.
Kafka cluster credentials. The following lists the different ways you can provide credentials.
Enter an existing service account resource ID.
Create a Confluent Cloud service account for the connector. Make sure to review the ACL entries required in the service account documentation. Some connectors have specific ACL requirements.
Create a Confluent Cloud API key and secret. To create a key and secret, you can use confluent api-key create or you can autogenerate the API key and secret directly in the Cloud Console when setting up the connector.
Confluent Cloud Schema Registry must be enabled for your cluster, if you are using a messaging schema (like Apache Avro). See Work with schemas and data contracts.
Using the Confluent Cloud Console
Step 1: Launch your Confluent Cloud cluster
To create and launch a Kafka cluster in Confluent Cloud, see Create a kafka cluster in Confluent Cloud.
Step 2: Add a connector
In the left navigation menu, click Connectors. If you already have connectors in your cluster, click + Add connector.
Step 3: Select your connector
Click the Google Cloud Storage Source connector card.

Step 4: Enter the connector details
Note
Be sure you have all your prerequisites completed.
An asterisk ( * ) designates a required entry.
Select the way you want to provide Kafka Cluster credentials. You can choose one of the following options:
My account: This setting allows your connector to globally access everything that you have access to. With a user account, the connector uses an API key and secret to access the Kafka cluster. This option is not recommended for production.
Service account: This setting limits the access for your connector by using a service account. This option is recommended for production.
Use an existing API key: This setting allows you to specify an API key and a secret pair. You can use an existing pair or create a new one. This method is not recommended for production environments.
Note
Freight clusters support only service accounts for Kafka authentication.
Click Continue.
Upload the GCP credentials file. You can download the credentials as a JSON file.
Enter the GCS bucket name.
Under GCP credentials, select how you want to authenticate with GCP:
If you select Google Cloud service account, upload your Google Cloud credentials JSON file. For information about how to set these up, see Create credentials.
If you select Google service account impersonation, choose an existing integration name under Provider integration name dropdown that has access to your resource or create a new provider integration. For more information, see Manage a Google Cloud Provider Integration.
Under the Google Cloud Storage details section, enter the GCS bucket name.
Click Continue.
Note
Configuration properties that are not shown in the Cloud Console use the default values. See Configuration Properties for all property values and definitions.
Select an Input message format: Supports AVRO, JSON (schemaless), STRING, or BYTES. A valid schema must be available in Schema Registry to use a schema-based message format, like Avro. Refer to Confluent Cloud connector limitations for additional information.
Select an Output Kafka record value format: Defaults to the file format selected for the input message format. AVRO, BYTES, JSON, JSON_SR, PROTOBUF, and STRING. A valid schema must be available in Schema Registry if using a schema-based format.
Enter the Topic Name Regex Patterns. A list of topics along with a regex expression of the files which are to be sent to that topic. For example,
"my-topic:.*"sends all files to"my-topic". The expression"special-topic:.*\.json+*"” sends only files ending with".json"to"special-topic". The connector ignores (doesn’t source) other files not matching any patterns. The connector sends files that match multiple mappings to the first topic in the list that maps the file.Enter a Topics directory. This is a top-level directory name where data is stored in the bucket. Defaults to
topics.Show advanced configurations
Schema context: Select a schema context to use for this connector, if using a schema-based data format. This property defaults to the Default context, which configures the connector to use the default schema set up for Schema Registry in your Confluent Cloud environment. A schema context allows you to use separate schemas (like schema sub-registries) tied to topics in different Kafka clusters that share the same Schema Registry environment. For example, if you select a non-default context, a Source connector uses only that schema context to register a schema and a Sink connector uses only that schema context to read from. For more information about setting up a schema context, see What are schema contexts and when should you use them?.
Auto-restart policy
Enable Connector Auto-restart: Control the auto-restart behavior of the connector and its task in the event of user-actionable errors. Defaults to
true, enabling the connector to automatically restart in case of user-actionable errors. Set this property tofalseto disable auto-restart for failed connectors. In such cases, you would need to manually restart the connector.
GCS Part Upload Retries. This is the number of times the connector retries uploading a GCS part. Defaults to
3retries. When set to0, the connector does not retry an upload that fails.Enter the Retry Backoff time in milliseconds (ms). This sets how many ms to wait before attempting the first retry of a failed request. Upon a failure, this connector may wait up to twice as long as the previous wait, up to the maximum number of retries. This avoids retrying in a tight loop under failure scenarios.
Enter a Directory Delimiter Character. The pattern to use as the delimiter character for directories. Defaults to
/.Select the Behavior on error. Defaults to
FAIL.Select a Byte Array Line Separator. String inserted between records when using ByteArrayFormat as input.data.format. Defaults to
\\nand may contain escape sequences like\\n. An input record that contains the line separator looks like multiple records in the storage object input.Enter a Task Batch Size: The number of files assigned to each task at a time. Defaults to
10. The maximum value supported is2000and the minimum value is1.Enter a File Discovery Starting Timestamp. A UNIX timestamp (that is, seconds since Jan 1, 1970 UTC) that denotes where to start processing files. The connector ignores any file encountered having an earlier creation time. Defaults to
0, which is Jan 1, 1970 (i.e., the beginning of data in the bucket).Enter an GCS poll interval in milliseconds (ms). Defaults to
60000ms (one minute). The minimum interval allowed is1000ms (one second).Set the Max records per poll. The maximum amount of records to return each time the connector polls storage. Defaults to
200. The maximum value supported is10000and the minimum value is1.
Transforms
Single Message Transforms: To add a new SMT, see Add transforms. For more information about unsupported SMTs, see Unsupported transformations.
See Configuration Properties for all property values and definitions.
Click Continue.
Based on the number of topic partitions you select, you will be provided with a recommended minimum number of tasks.
Enter the maximum number of tasks. The connector supports running one or more tasks. More tasks can improve performance.
Click Continue.
Verify the connection details by previewing the running configuration.
Once you’ve validated that the properties are configured to your satisfaction, click Continue.
Tip
For information about previewing your connector output, see Data Previews for Confluent Cloud Connectors.
Step 5: Check the Kafka topic
After the connector is running, verify that messages are populating your Kafka topic.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect Usage Examples section.
Using the Confluent CLI
Complete the following steps to set up and run the connector using the Confluent CLI.
Note
Make sure you have all your prerequisites completed.
Step 1: List the available connectors
Enter the following command to list available connectors:
confluent connect plugin list
Step 2: List the connector configuration properties
Enter the following command to show the connector configuration properties:
confluent connect plugin describe <connector-plugin-name>
The command output shows the required and optional configuration properties.
Step 3: Create the connector configuration file
Create a JSON file that contains the connector configuration properties. The following example shows the required connector properties.
{
"connector.class": "GcsSource",
"name": "GcsSourceConnector_0",
"topic.regex.list": "kafka-topic-for-json:.*",
"kafka.auth.mode": "SERVICE_ACCOUNT",
"kafka.service.account.id": "<service-account-resource-ID>",
"input.data.format": "JSON",
"output.data.format": "JSON",
"gcs.credentials.json": "",
"gcs.bucket.name": "<bucket-name>",
"tasks.max": "1",
}
Note the following required property definitions:
"connector.class": Identifies the connector plugin name."name": Sets a name for your new connector."topic.regex.list": A list of topics along with a regex expression of the files which are to be sent to that topic. In the example above,"kafka-topic-for-json:.*"sends all files to"kafka-topic-for-json". The expression"special-topic:.*\.json+*"” sends only files ending with".json"to"special-topic". The connector ignores (doesn’t source) other files not matching any patterns. The connector sends files that match multiple mappings to the first topic in the list that maps the file.Note
The
topic.regex.listproperty matches the full GCS path (for example,folder/file.txt), not just the filename. Note the following regex pattern that must account for the full path to match correctly.Correct:
topic:.*file.*(includes.*at the beginning)Incorrect:
topic:file.*
"kafka.auth.mode": Identifies the connector authentication mode you want to use. There are two options:SERVICE_ACCOUNTorKAFKA_API_KEY(the default). To use an API key and secret, specify the configuration propertieskafka.api.keyandkafka.api.secret, as shown in the example configuration (above). To use a service account, specify the Resource ID in the propertykafka.service.account.id=<service-account-resource-ID>. To list the available service account resource IDs, use the following command:confluent iam service-account list
For example:
confluent iam service-account list Id | Resource ID | Name | Description +---------+-------------+-------------------+------------------- 123456 | sa-l1r23m | sa-1 | Service account 1 789101 | sa-l4d56p | sa-2 | Service account 2
"input.data.format": Supports Avro, JSON (schemaless), String, or Bytes. A valid schema must be available in Schema Registry to use a schema-based message format, like Avro. Refer to Confluent Cloud connector limitations for additional information."output.data.format": Defaults to the file format selected for the input message format. AVRO, BYTES, JSON, JSON_SR, PROTOBUF, and STRING. A valid schema must be available in Schema Registry if using a schema-based format."gcs.credentials.json": This contains the contents of the downloaded JSON file. See Formatting Google Cloud credentials for details about how to format and use the contents of the downloaded credentials file."tasks.max": The total number of tasks to run in parallel. More tasks may improve performance.Transforms and Predicates: See the Single Message Transforms (SMT) documentation for details.
For configuration property values and descriptions, see Configuration Properties.
Formatting Google Cloud credentials
The contents of the downloaded credentials file must be converted to string format before it can be used in the connector configuration.
Convert the JSON file contents into string format.
Add the escape character
\before all\nentries 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\\nentries are easier to see. Most of the credentials key and other properties have been omitted.Tip
A script is available that converts the credentials to a string and also adds additional
\escape characters where needed. See Stringify Google Cloud Credentials.{ "connector.class": "GcsSource", "name": "GcsSourceConnector_0", "kafka.api.key": "<my-kafka-api-key>", "kafka.api.secret": "<my-kafka-api-secret>", ... omitted ... "gcs.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\"}", "tasks.max": "1" }
Add all the converted string content to the
"gcs.credentials.json"section of your configuration file as shown in the example above.
Step 4: Load the properties file and create the connector
Enter the following command to load the configuration and start the connector:
confluent connect cluster create --config-file <file-name>.json
For example:
confluent connect cluster create --config-file gcs-source-config.json
Example output:
Created connector GcsSourceConnector_0 lcc-ix4dl
Step 5: Check the connector status
Enter the following command to check the connector status:
confluent connect cluster list
Example output:
ID | Name | Status | Type
+-----------+------------------------+---------+--------+
lcc-ix4dl | GcsSourceConnector_0 | RUNNING | source
Step 6. Check the Kafka topic.
After the connector is running, verify records are populating the Kafka topic.
Note
The GCS Source connector loads and filters all object names in the bucket before it starts sourcing records. When starting up, the connector may display RUNNING but not show any throughput. This is because bucket loading is not finished. For buckets with a large amount of objects, bucket loading can take several minutes to complete.
For more information and examples to use with the Confluent Cloud API for Connect, see the Confluent Cloud API for Connect Usage Examples section.
Configuration Properties
Use the following configuration properties with the fully-managed connector. For self-managed connector property definitions and other details, see the connector docs in Self-managed connectors for Confluent Platform.
How should we connect to your data?
nameSets a name for your connector.
Type: string
Valid Values: A string at most 64 characters long
Importance: high
Which topic(s) do you want to send data to?
topic.regex.listA list of topics along with a regex expression of the files which are to be sent to that topic. For example: “my-topic:.*” will send all files to “my-topic”, while a list containing only the expression “special-topic:.*.json” will send only files starting with “.json” to “special-topic”, and all other files not matching any patterns will be ignored and not sourced. Files that match multiple mappings will be sent to the first topic in the list that maps the file. The
topic.regex.listproperty matches the full GCS path (for example,folder/file.txt), not just the filename.Type: list
Importance: high
Schema Config
schema.context.nameAdd a schema context name. A schema context represents an independent scope in Schema Registry. It is a separate sub-schema tied to topics in different Kafka clusters that share the same Schema Registry instance. If not used, the connector uses the default schema configured for Schema Registry in your Confluent Cloud environment.
Type: string
Default: default
Importance: medium
Kafka Cluster credentials
kafka.auth.modeKafka Authentication mode. It can be one of KAFKA_API_KEY or SERVICE_ACCOUNT. It defaults to KAFKA_API_KEY mode.
Type: string
Default: KAFKA_API_KEY
Valid Values: KAFKA_API_KEY, SERVICE_ACCOUNT
Importance: high
kafka.api.keyKafka API Key. Required when kafka.auth.mode==KAFKA_API_KEY.
Type: password
Importance: high
kafka.service.account.idThe Service Account that will be used to generate the API keys to communicate with Kafka Cluster.
Type: string
Importance: high
kafka.api.secretSecret associated with Kafka API key. Required when kafka.auth.mode==KAFKA_API_KEY.
Type: password
Importance: high
GCP credentials
provider.integration.idSelect an existing integration that has access to your resource. In case you need to integrate a new Google Service Account, use provider integration
Type: string
Importance: high
authentication.methodSelect how you want to authenticate with GCP.
Type: string
Default: Google cloud service account
Valid Values: Google cloud service account, Google service account impersonation
Importance: high
gcs.credentials.jsonGCP service account JSON file with read permissions for Google Cloud Storage.
Type: password
Importance: high
Google Cloud Storage details
gcs.bucket.nameThe name of the GCS bucket.
Type: string
Importance: high
gcs.part.retriesNumber of upload retries of a single GCS part. Zero means no retries
Type: int
Default: 3
Importance: medium
gcs.retry.backoff.msHow long to wait in milliseconds before attempting the first retry of a failed GCS request. Upon a failure, this connector may wait up to twice as long as the previous wait, up to the maximum number of retries. This avoids retrying in a tight loop under failure scenarios.
Type: int
Default: 200
Importance: medium
Input and output messages
input.data.formatSets the input message format. Valid entries are AVRO, JSON, or BYTES. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO.
Type: string
Importance: high
output.data.formatSet the output Kafka record value format. Valid entries are AVRO, JSON_SR, PROTOBUF, JSON or BYTES. Note that you need to have Confluent Cloud Schema Registry configured if using a schema-based message format like AVRO. Note that the output message format defaults to the value in the Input Message Format field. If no value for this property is provided, the value specified for the ‘input.data.format’ property is used.
Type: string
Importance: high
Storage
topics.dirTop-level directory (in the GCS bucket) where data to be ingested is stored.
Type: string
Default: topics
Importance: high
directory.delimDirectory delimiter pattern.
Type: string
Default: /
Importance: medium
behavior.on.errorShould the task halt when it encounters an error or continue to the next file.
Type: string
Default: FAIL
Importance: high
format.bytearray.separatorString inserted between records for ByteArrayFormat. Defaults to n and may contain escape sequences like n. An input record that contains the line separator looks like multiple records in the storage object input.
Type: string
Default: “”
Importance: medium
task.batch.sizeThe number of files assigned to each task at a time
Type: int
Default: 10
Valid Values: [1,…,2000]
Importance: high
file.discovery.starting.timestampA Unix timestamp (in epoch milliseconds since Jan 1, 1970 UTC) that denotes where to start processing files. The connector ignores any file with a creation time earlier than this timestamp. Note that the connector only uses this configuration property when no offsets are stored for a connector. This parameter allows new connectors to start from a specific timestamp instead of reading all files in a bucket.
Type: long
Default: 0
Importance: high
Data polling policy
gcs.poll.interval.msFrequency in milliseconds to poll for new or removed folders. This may result in updated task configurations starting to poll for data in added folders or stopping polling for data in removed folders
Type: long
Default: 60000 (1 minute)
Valid Values: [1000,…]
Importance: medium
record.batch.max.sizeThe maximum amount of records to return each time storage is polled.
Type: int
Default: 200
Valid Values: [1,…,10000]
Importance: medium
Number of tasks for this connector
tasks.maxThe total number of tasks to run in parallel.
Type: int
Valid Values: [1,…,1000]
Importance: high
Additional Configs
header.converterThe converter class for the headers. This is used to serialize and deserialize the headers of the messages.
Type: string
Importance: low
producer.override.compression.typeThe compression type for all data generated by the producer. Valid values are none, gzip, snappy, lz4, and zstd.
Type: string
Importance: low
producer.override.linger.msThe producer groups together any records that arrive in between request transmissions into a single batched request. More details can be found in the documentation: https://docs.confluent.io/platform/current/installation/configuration/producer-configs.html#linger-ms.
Type: long
Valid Values: [100,…,1000]
Importance: low
value.converter.allow.optional.map.keysAllow optional string map key when converting from Connect Schema to Avro Schema. Applicable for Avro Converters.
Type: boolean
Importance: low
value.converter.auto.register.schemasSpecify if the Serializer should attempt to register the Schema.
Type: boolean
Importance: low
value.converter.connect.meta.dataAllow the Connect converter to add its metadata to the output schema. Applicable for Avro Converters.
Type: boolean
Importance: low
value.converter.enhanced.avro.schema.supportEnable enhanced schema support to preserve package information and Enums. Applicable for Avro Converters.
Type: boolean
Importance: low
value.converter.enhanced.protobuf.schema.supportEnable enhanced schema support to preserve package information. Applicable for Protobuf Converters.
Type: boolean
Importance: low
value.converter.flatten.unionsWhether to flatten unions (oneofs). Applicable for Protobuf Converters.
Type: boolean
Importance: low
value.converter.generate.index.for.unionsWhether to generate an index suffix for unions. Applicable for Protobuf Converters.
Type: boolean
Importance: low
value.converter.generate.struct.for.nullsWhether to generate a struct variable for null values. Applicable for Protobuf Converters.
Type: boolean
Importance: low
value.converter.int.for.enumsWhether to represent enums as integers. Applicable for Protobuf Converters.
Type: boolean
Importance: low
value.converter.latest.compatibility.strictVerify latest subject version is backward compatible when use.latest.version is true.
Type: boolean
Importance: low
value.converter.object.additional.propertiesWhether to allow additional properties for object schemas. Applicable for JSON_SR Converters.
Type: boolean
Importance: low
value.converter.optional.for.nullablesWhether nullable fields should be specified with an optional label. Applicable for Protobuf Converters.
Type: boolean
Importance: low
value.converter.optional.for.proto2Whether proto2 optionals are supported. Applicable for Protobuf Converters.
Type: boolean
Importance: low
value.converter.scrub.invalid.namesWhether to scrub invalid names by replacing invalid characters with valid characters. Applicable for Avro and Protobuf Converters.
Type: boolean
Importance: low
value.converter.use.latest.versionUse latest version of schema in subject for serialization when auto.register.schemas is false.
Type: boolean
Importance: low
value.converter.use.optional.for.nonrequiredWhether to set non-required properties to be optional. Applicable for JSON_SR Converters.
Type: boolean
Importance: low
value.converter.wrapper.for.nullablesWhether nullable fields should use primitive wrapper messages. Applicable for Protobuf Converters.
Type: boolean
Importance: low
value.converter.wrapper.for.raw.primitivesWhether a wrapper message should be interpreted as a raw primitive at root level. Applicable for Protobuf Converters.
Type: boolean
Importance: low
errors.toleranceUse this property if you would like to configure the connector’s error handling behavior. WARNING: This property should be used with CAUTION for SOURCE CONNECTORS as it may lead to dataloss. If you set this property to ‘all’, the connector will not fail on errant records, but will instead log them (and send to DLQ for Sink Connectors) and continue processing. If you set this property to ‘none’, the connector task will fail on errant records.
Type: string
Default: none
Importance: low
key.converter.key.subject.name.strategyHow to construct the subject name for key schema registration.
Type: string
Default: TopicNameStrategy
Importance: low
value.converter.decimal.formatSpecify the JSON/JSON_SR serialization format for Connect DECIMAL logical type values with two allowed literals:
BASE64 to serialize DECIMAL logical types as base64 encoded binary data and
NUMERIC to serialize Connect DECIMAL logical type values in JSON/JSON_SR as a number representing the decimal value.
Type: string
Default: BASE64
Importance: low
value.converter.flatten.singleton.unionsWhether to flatten singleton unions. Applicable for Avro and JSON_SR Converters.
Type: boolean
Default: false
Importance: low
value.converter.ignore.default.for.nullablesWhen set to true, this property ensures that the corresponding record in Kafka is NULL, instead of showing the default column value. Applicable for AVRO,PROTOBUF and JSON_SR Converters.
Type: boolean
Default: false
Importance: low
value.converter.reference.subject.name.strategySet the subject reference name strategy for value. Valid entries are DefaultReferenceSubjectNameStrategy or QualifiedReferenceSubjectNameStrategy. Note that the subject reference name strategy can be selected only for PROTOBUF format with the default strategy being DefaultReferenceSubjectNameStrategy.
Type: string
Default: DefaultReferenceSubjectNameStrategy
Importance: low
value.converter.replace.null.with.defaultWhether to replace fields that have a default value and that are null to the default value. When set to true, the default value is used, otherwise null is used. Applicable for JSON Converter.
Type: boolean
Default: true
Importance: low
value.converter.schemas.enableInclude schemas within each of the serialized values. Input messages must contain schema and payload fields and may not contain additional fields. For plain JSON data, set this to false. Applicable for JSON Converter.
Type: boolean
Default: false
Importance: low
value.converter.value.subject.name.strategyDetermines how to construct the subject name under which the value schema is registered with Schema Registry.
Type: string
Default: TopicNameStrategy
Importance: low
Auto-restart policy
auto.restart.on.user.errorEnable connector to automatically restart on user-actionable errors.
Type: boolean
Default: true
Importance: medium
Egress allowlist
connector.egress.whitelistType: string
Default: “”
Importance: high
Next Steps
For an example that shows fully-managed Confluent Cloud connectors in action with Confluent Cloud for Apache Flink, see the Cloud ETL Demo. This example also shows how to use Confluent CLI to manage your resources in Confluent Cloud.
