Quick Start for Confluent Cloud

Confluent Cloud is a fully managed, cloud-native data streaming platform powered by Apache Kafka®. This quick start guide helps you begin streaming data by showing you how to create a cluster, add a topic, and produce data.

Why use Confluent Cloud instead of managing Kafka yourself?

Confluent Cloud eliminates the operational complexity of Kafka with:

  • Automatic scaling and reliability

  • Built-in security, monitoring, and schema management

  • Lower total cost of ownership and faster development

Compare Confluent Cloud and Apache Kafka or sign up for Confluent Cloud to get started.

Considerations
  • This quick start gets you up and running with Confluent Cloud using a Basic Kafka cluster.

  • The first section shows how to use Confluent Cloud to create topics, and produce and consume data to and from the cluster.

  • The second section walks you through how to use Confluent Cloud for Apache Flink® to run queries on the data using SQL syntax.

  • The quick start workflows assume you already have a working Confluent Cloud environment, which includes a Stream Governance package. To learn more about Stream Governance packages, features, and environment setup workflows, see Manage Stream Governance Packages in Confluent Cloud.

  • Confluent Cloud has a web interface called the Cloud Console, a local command line interface, and REST APIs. Use the Cloud Console to manage cluster resources, settings, and billing. Use the Confluent CLI and REST APIs to create and manage topics and more.

Prerequisites

Section 1: Create a cluster and add a topic

Follow the steps in this section to set up a Kafka cluster on Confluent Cloud and produce data to Kafka topics on the cluster.

Step 1: Create a Kafka cluster in Confluent Cloud

In this step, you create and launch a basic Kafka cluster inside your default environment.

  1. Sign in to Confluent Cloud at https://confluent.cloud.

  2. Click Add cluster.

  3. On the Create cluster page, for the Basic cluster, select Begin configuration.

    Create cluster page in Confluent Cloud.

    This example creates a Basic Kafka cluster, which supports single-zone availability. For information about other cluster types, see Kafka Cluster Types in Confluent Cloud.

  4. On the Region/zones page, choose a cloud provider, region, and select a single availability zone.

  5. Select Continue.

    If you haven’t set up a payment method, you see the Set payment page. Enter a payment method and select Review.

  6. On the Create cluster page, specify a cluster name, review the configuration and cost information, and then select Launch cluster.

Depending on the chosen cloud provider and other settings, it might take a few minutes to provision your cluster, but after the cluster has provisioned, the Cluster Overview page displays.

Cluster Overview page in Confluent Cloud.

Now you can configure apps and data on your new cluster.

  1. Log in or sign up to Confluent Cloud:

    Log in:

    confluent login
    
  2. Create a Kafka cluster:

    confluent kafka cluster create <name> [flags]
    

    For example:

    confluent kafka cluster create quickstart_cluster --cloud "aws" --region "us-west-2"
    

Create a Kafka cluster.

Request:

POST /cmk/v2/clusters
Host: api.confluent.cloud

{
   "spec": {
      "display_name": "quickstart_cluster",
      "availability": "SINGLE_ZONE",
      "cloud": "{provider}",
      "region": "{region}",
      "config": {
         "kind": "Basic"
      },
      "environment": {
         "id": "env-a12b34"
      }
   }
}

Response:

{
   "api_version": "cmk/v2",
   "id": "lkc-000000",
   "kind": "Cluster",
   "metadata": {
      "created_at": "2022-11-21T22:50:07.496522Z",
      "resource_name": "crn://confluent.cloud/organization=example1-org1-1111-2222-33aabbcc444dd55/environment=env-00000/cloud-cluster=lkc-000000/kafka=lkc-000000",
      "self": "https://api.confluent.cloud/cmk/v2/clusters/lkc-000000",
      "updated_at": "2022-11-21T22:50:07.497443Z"
   },
   "spec": {
      "api_endpoint": "https://pkac-{00000}.{region}.{provider}.confluent.cloud",
      "availability": "SINGLE_ZONE",
      "cloud": "{provider}",
      "config": {
            "kind": "Basic"
      },
      "display_name": "quickstart_cluster",
      "environment": {
            "api_version": "org/v2",
            "id": "env-a12b34",
            "kind": "Environment",
            "related": "https://api.confluent.cloud/org/v2/environments/env-a12b34",
            "resource_name": "crn://confluent.cloud/organization=example1-org1-1111-2222-33aabbcc444dd55/environment=env-a12b34}"
      ,
      "http_endpoint": "https://pkc-{00000}.{region}.{provider}.confluent.cloud:443",
      "kafka_bootstrap_endpoint": "SASL_SSL://pkc-{00000}.{region}.{provider}.confluent.cloud:9092",
      "region": "{region}"
   },
   "status": {
      "phase": "PROVISIONING"
   }
}

Step 2: Create a Kafka topic

In this step, you create a users Kafka topic by using the Cloud Console. A topic is a unit of organization for a cluster, and is essentially an append-only log. For more information about topics, see What is Apache Kafka.

  1. From the navigation menu, click Topics, and then click Create topic.

  2. In the Topic name field, type “users” and then select Create with defaults.

    Topics page in Confluent Cloud with the new topic.

The users topic is created on the Kafka cluster and is available for use by producers and consumers.

The success message might prompt you to take an action, but continue with Step 3: Create a sample producer.

Create a topic:

confluent kafka topic create <name> [flags]

For example:

confluent kafka topic create users --cluster lkc-000000

Create a topic:

Request:

POST /kafka/v3/clusters/{cluster_id}/topics
Host: pkc-{00000}.{region}.{provider}.confluent.cloud

{
   "topic_name": "users",
   "partitions_count": 6,
   "replication_factor": 3,
   "configs": [{
         "name": "cleanup.policy",
         "value": "delete"
      },
      {
         "name": "compression.type",
         "value": "gzip"
      }
   ]
}

Response:

{
   "kind": "KafkaTopic",
   "metadata": {
      "self": "https://pkc-{00000}.{region}.{provider}.confluent.cloud/kafka/v3/clusters/quickstart/topics/users",
      "resource_name": "crn:///kafka=quickstart/topic=users"
   },
   "cluster_id": "quickstart",
   "topic_name": "users",
   "is_internal": false,
   "replication_factor": 3,
   "partitions_count": 1,
   "partitions": {
      "related": "https://pkc-{00000}.{region}.{provider}.confluent.cloud/kafka/v3/clusters/cluster-1/topics/topic-X/partitions"
   },
   "configs": {
      "related": "https://pkc-{00000}.{region}.{provider}.confluent.cloud/kafka/v3/clusters/cluster-1/topics/topic-X/configs"
   },
   "partition_reassignments": {
      "related": "https://pkc-{00000}.{region}.{provider}.confluent.cloud/kafka/v3/clusters/cluster-1/topics/topic-X/partitions/-/reassignments"
   }
}

Step 3: Create a sample producer

You can produce example data to your Kafka cluster by using the hosted Datagen Source Connector for Confluent Cloud.

  1. From the navigation menu, select Connectors.

    To open Confluent Cloud at Connectors: https://confluent.cloud/go/connectors.

  2. In the Search box, type “datagen”.

  3. From the search results, select the Datagen Source connector.

    Searching for the Datagen connector in Confluent Cloud.

    Tip

    If you see the Launch Sample Data box, select Additional configuration.

  4. On the Launch Sample Data dialog, select the Users template, and click Additional configuration.

  5. On the Topic selection dialog, select the “users” topic you created in the previous section and click Continue.

  6. In the Kafka credentials dialog, select My account, and click Generate API key & download, then click Continue.

    This creates an API key and secret that allows the connector to access your cluster, and downloads the key and secret to your computer. The key and secret are required for the connector and also for the Confluent CLI and ksqlDB CLI to access your cluster.

    Note

    An API key and associated secret apply to the active Kafka cluster. If you add a new cluster, you must create a new API key for producers and consumers on the new Kafka cluster. For more information, see Use API Keys to Authenticate to Confluent Cloud.

  7. On the Configuration page, select JSON_SR for the output record value format, Users for the template, and click Continue.

  8. For Connector sizing, leave the slider at the default of 1 task and click Continue.

  9. On the Review and launch page, select the text in the Connector name box and replace it with “DatagenSourceConnector_users”.

  10. Click Continue to start the connector.

    The status of your new connector should read Provisioning, which lasts for a few seconds. When the status changes to Running, your connector is producing data to the users topic.

    Running Datagen Source connector in Confluent Cloud.
  1. Create an API key:

    confluent api-key create --resource <cluster_id> [flags]
    

    For example:

    confluent api-key create --resource lkc-000000
    

    Example output:

    +---------+------------------------------------------------------------------+
    | API Key | EXAMPLEERFBSSSLK                                                 |
    | Secret  | EXAMPLEEkYXOtOmn+En8397gCaeX05j0szygokwLRk1ypVby1UsgZpZLX7gJGR4G |
    +---------+------------------------------------------------------------------+
    

    It might take a few minutes for the API key to be ready. Save the API key and secret. The secret is not retrievable later.

  2. Create a JSON file named quick-start.json and copy and paste the following configuration properties into the file:

    {
       "name" : "DatagenSourceConnector_users",
       "connector.class": "DatagenSource",
       "kafka.auth.mode": "KAFKA_API_KEY",
       "kafka.api.key": "[Add your cluster API key here]",
       "kafka.api.secret" : "[Add your cluster API secret here]",
       "kafka.topic" : "users",
       "output.data.format" : "JSON_SR",
       "quickstart" : "USERS",
       "tasks.max" : "1"
    }
    
  3. Replace [Add your cluster API key here] and [Add your cluster API secret here] with your API key and secret.

  4. Create the sample producer:

    confluent connect cluster create --config-file <file-name>.json --cluster <cluster_id>
    

    For example:

    confluent connect cluster create --config-file quick-start.json --cluster lkc-000000
    

Create a producer.

To create a producer with the Confluent Cloud APIs, you need two API keys:

  • Cloud API key added to the header for authorization

  • Kafka cluster API key added to the body for access to the cluster

Use the Confluent CLI or the Cloud Console to generate an API key for the Kafka cluster. For more information, see Authentication in the API reference.

Request:

POST /connect/v1/environments/{environment_id}/clusters/{cluster_id}/connectors
Host: api.confluent.cloud

{
   "name": "DatagenSourceConnector_users",
   "config": {
      "name": "DatagenSourceConnector_users"
      "connector.class": "DatagenSource",
      "kafka.auth.mode": "KAFKA_API_KEY",
      "kafka.api.key": "[Add your cluster API key here]",
      "kafka.api.secret" : "[Add your cluster API secret here]",
      "kafka.topic" : "users",
      "output.data.format" : "JSON_SR",
      "quickstart" : "USERS",
      "tasks.max" : "1"
   }
}

Replace [Add your cluster API key here] and [Add your cluster API secret here] with your cluster API key and secret.

Response:

{
   "name": "DatagenSourceConnector_users",
   "type": "source",
   "config": {
      "cloud.environment": "prod",
      "cloud.provider": "{provider}",
      "connector.class": "DatagenSource",
      "kafka.api.key": "[Your cluster API key]",
      "kafka.api.secret": "[Your cluster API secret]",
      "kafka.auth.mode": "KAFKA_API_KEY",
      "kafka.endpoint": "SASL_SSL://pkc-{00000}.{region}.{provider}.confluent.cloud:9092",
      "kafka.region": "{region}",
      "kafka.topic": "users1",
      "name": "DatagenSourceConnector_users",
      "output.data.format": "JSON_SR",
      "quickstart": "USERS",
      "tasks.max": "1"
   },
   "tasks": []
}

Step 4: View messages

Your new users topic is now receiving messages. Use Confluent Cloud Console to see the data.

  1. From the navigation menu, select Topics to show the list of topics in your cluster.

    Topics page in Confluent Cloud.
  2. Select the users topic.

  3. In the users topic detail page, select the Messages tab to view the messages being produced to the topic.

    Messages page in Confluent Cloud.

Step 5: Inspect the data stream

Use Stream Lineage to track data movement through your cluster.

  1. Click Lineage in the navigation menu.

  2. Click the DatagenSourceConnector_users node, which is the connector that you created in Step 3. The details overview shows graphs for total production and other data.

    Source connector details in Confluent Cloud.
  3. Dismiss this view and select the topic labeled users. Click Overview to show graphs for total throughput and other data. Click the other tabs to view the schema associated with the topic (if there is one defined), along with metadata and messages.

    Topic details in Confluent Cloud.
  4. Click the arrow on the canvas border to re-open the navigation menu.

Step 6: Delete resources (optional)

Skip this step if you plan to move on to Section 2: Query streaming data with Flink SQL and learn how to use Flink SQL statements to query your data.

If you don’t plan to complete Section 2 and you’re ready to quit the Quick Start, delete the resources you created to avoid unexpected charges to your account.

  • Delete the connector:

    1. From the navigation menu, select Connectors.

    2. Click DatagenSourceConnector_users and choose the Settings tab.

    3. Click Delete connector, enter the connector name (DatagenSourceConnector_users), and click Confirm.

  • Delete the topic:

    1. From the navigation menu, click Topics, select the users topic, and then choose the Configuration tab.

    2. Click Delete topic, enter the topic name (users), and select Continue.

  • Delete the cluster:

    1. From the navigation menu, select Cluster Settings.

    2. Click Delete cluster, enter the cluster name, and click Continue.

  1. Delete the connector:

    confluent connect cluster delete <connector-id> [flags]
    

    For example:

    confluent connect cluster delete lcc-aa1234 --cluster lkc-000000
    
  2. Delete the topic:

    confluent kafka topic delete <topic name> [flags]
    

    For example:

    confluent kafka topic delete users --cluster lkc-000000
    
  3. Delete the cluster.

    confluent kafka cluster delete <id> [flags]
    

    For example (text you must enter is highlighted):

    confluent kafka cluster delete lkc-123exa
    
    Are you sure you want to delete Kafka cluster "lkc-123exa"?
    To confirm, type "my-new-name". To cancel, press Ctrl-C:
    
    my-new-name
    
    Deleted Kafka cluster "lkc-123exa".
    

Delete a producer.

Request:

DELETE /connect/v1/environments/{environment_id}/clusters/{kafka_cluster_id}/connectors/{connector_name}
Host: api.confluent.cloud

Delete a topic.

Request:

DELETE /kafka/v3/clusters/{kafka_cluster_id}/topics/{topic_name}
Host: pkc-{0000}.{region}.{provider}.confluent.cloud

Delete a cluster.

Request:

DELETE /cmk/v2/clusters/{id}?environment={environment_id}
Host: api.confluent.cloud