<a id="use-kafka-tool-ccloud"></a>

# How to Use Kafka Tools With Confluent Cloud

Apache Kafka® is an open-source distributed streaming system used for stream processing,
real-time data pipelines, and data integration at scale. Originally created to handle
real-time data feeds at LinkedIn in 2011, Kafka quickly evolved from a messaging queue to a
full-fledged event streaming platform, capable of handling over one
million messages per second, or trillions of messages per day.

Confluent Cloud is the fully managed Kafka service that Confluent provides. It enables you to create and manage Kafka clusters in the cloud,
and provides a web-based console for managing your clusters and topics.

As a result, there are times when you may want to use one of the CLI tools that Kafka provides with your Confluent Cloud cluster.

You can do this by creating a configuration file that contains basic connectivity details such as the bootstrap server
and a cluster API key and secret. You can use this file with any Kafka tool that accepts a configuration file.
Some of the tools that provide a configuration option, and the option to specify the configuration file are listed in the table that follows:

| Kafka Tool                                                         | Config property option   |
|--------------------------------------------------------------------|--------------------------|
| [kafka-configs.sh](kafka-tools.md#kafka-configs-usage)             | `command-config`         |
| [kafka-console-producer.sh](kafka-tools.md#console-producer-usage) | `consumer.config`        |
| [kafka-console-consumer.sh](kafka-tools.md#console-consumer-usage) | `producer.config`        |
| [kafka-groups.sh](kafka-tools.md#kafka-consumer-group-usage)       | `command-config`         |

Note that you might not be able to use every Kafka tool with every Confluent Cloud cluster type.

## Create a configuration file

1. Create a file named `cloud.properties` and save it in a secure location. You will populate
   this file with credentials to access your Confluent Cloud account so you **must** keep it in a safe place.
   Add the following content to the file:
   ```none
   ssl.endpoint.identification.algorithm=https
   sasl.mechanism=PLAIN
   request.timeout.ms=20000
   bootstrap.servers=<cloud-bootstrap-server>
   retry.backoff.ms=500
   sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="<cloud-key>" password="<cloud-password>";
   security.protocol=SASL_SSL
   ```

Next, you will populate the file with your Confluent Cloud cluster information:

1. Sign in to your Confluent Cloud account.
2. In the Cloud Console, navigate to the cluster you want to work with.
3. Navigate to the **Cluster Settings** page and copy the **Bootstrap server** to the bootstrap server entry
   in the config file. You also should save the bootstrap server for use with the Kafka tools.
   ![image](images/ccloud-bootstrap-server.png)
4. Next, create an API key and add the key and password to the configuration file.
   In the Cloud Console, navigate to **API Keys**, **Add key** and copy the key to the **Username** field, and the secret to the **Password** field in the
   config file and save the file. For more about how to create a API key for your cluster, including with the Confluent CLI,
   see [Create a resource API key](/cloud/current/access-management/authenticate/api-keys/api-keys.html#create-a-resource-api-key).

## Call the tool

After you have set up the configuration file that references your cluster, you can use it with some of the
Kafka tools. You will also need the bootstrap server of the Confluent Cloud cluster when you call a tool.

The following example shows you how to write messages to a Confluent Cloud cluster topic named `test` with the
[kafka-console-producer tool](kafka-tools.md#console-producer-usage). In this example, the configuration file and bootstrap server
are specified as options. Make sure the topic already exists on the cluster.

```none
./bin/kafka-console-producer.sh --producer.config ../path/to/secure/cloud.properties --bootstrap-server pkc-12345.us-west4.gcp.confluent.cloud:9092 --topic test
```

Now enter some messages at the prompt (>):

```none
> first event message
> second event message
```

To test your calls, navigate to the Cloud Console, select the topic, and click the **Messages** tab.
You should see the messages you just produced.

![image](images/ccloud-topic-messages.png)

## Related content

- [Kafka Command-Line Interface (CLI) Tools](kafka-tools.md#kafka-cli-tools)
- [View Consumer Group Info in Kafka](manage-consumer-groups.md#manage-consumer-groups)
- [Kafka Topic Operations](topic-operations.md#topic-operations)
