<a id="controlcenter-userguide-ksql"></a>

# Manage ksqlDB Using Control Center for Confluent Platform

Control Center provides the convenience of running streaming queries on one or more
ksqlDB clusters within its graphical user interface. The ksqlDB feature is
[enabled](#c3-enable-disable-ksql) by default in Control Center.

#### IMPORTANT
If [RBAC](security/c3-rbac.md#c3-rbac-ksql) is enabled, the ability to view
and use ksqlDB in Control Center is determined by the assigned roles and associated privileges configured
in both ksqlDB and Control Center.

For more information about ksqlDB, see [ksqlDB for Confluent Platform](/platform/current/ksqldb/overview.html#ksql-home).

<a id="c3-config-ksql-cluster"></a>

## Configure Control Center for ksqlDB clusters

When you start a local Confluent Platform installation by using the [confluent local services start](https://docs.confluent.io/confluent-cli/3.15/command-reference/local/services/confluent_local_services_start.html)
command from the Confluent CLI, a default ksqlDB cluster named **ksqlDB**
is created for you.

To configure Control Center to communicate with your own multiple ksqlDB
clusters in a production environment, set the following options in the
appropriate `control-center.properties` files:

- `confluent.controlcenter.ksql.<name of cluster>.url = <list of urls>`
- `confluent.controlcenter.ksql.<name of cluster>.advertised.url = <list of urls>`

These options are required for connecting Control Center to your ksqlDB clusters.
For more information, see the [ksqlDB](installation/configuration.md#controlcenter-ksql-settings) options in the
[Control Center Configuration Reference for Confluent Platform](installation/configuration.md#controlcenter-configuration).

#### IMPORTANT
Be sure to review [Connect ksqlDB Server Instances to Confluent Control Center on Confluent Platform](/platform/current/ksqldb/integrate-ksql-with-confluent-control-center.html#integrate-ksql-with-confluent-control-center)
: for more information on configurations for both ksqlDB and Control Center.

Links to comprehensive ksqlDB documentation are available throughout the
Control Center ksqlDB web interface.

<a id="c3-ksql-clusters-page"></a>

## ksqlDB clusters page

To access the ksqlDB clusters page, click the cluster from the navigation
bar and select **ksqlDB** from the cluster submenu.

Use the ksqlDB clusters page to:

- View a summary of all ksqlDB clusters connected to Control Center.
- Search for a ksqlDB cluster being managed by the Control Center instance.
- Browse topic messages.
- View the number of running queries, registered streams, and registered tables
  for each ksqlDB cluster.
- Navigate to the [ksqlDB Editor](#c3-ksql-editor), [Streams](#c3-ksql-streams),
  [Tables](#c3-ksql-tables), and [Persistent Queries](#c3-ksql-running-queries) for each ksqlDB
  cluster. Click the ksqlDB cluster name link to navigate to the ksqlDB
  Editor and other pages.

![ksqlDB clusters list page in Confluent Control Center](images/c3-ksql-app-list.png)

<a id="c3-ksql-editor"></a>

## ksqlDB Editor

To access the ksqlDB Editor page, click the ksqlDB cluster name in the
[ksqlDB clusters page](#c3-ksql-clusters-page).

Use the ksqlDB Editor page to create streams and tables, run SQL queries, and
browse messages.

![ksqlDB Editor in Confluent Control Center](images/c3-ksql-query-table.png)

After creating streams and tables, the resizeable streams and tables pane is
populated with the defined streams and tables for the cluster, beyond the
default `KSQL_PROCESSING_LOG`:

- Streams are indicated with a blue **St** expandable node: ![str](images/c3-ksql-str-icon.png)
- Tables are indicated with a brown **Tb** expandable node: ![tbl](images/c3-ksql-tbl-icon.png)

Click a node to view the schema for a stream or table.

![ksqlDB Editor in Confluent Control Center browse streams and table schemas pane](images/c3-ksql-streams-and-tables-pane.png)

A **Search** box enables searching for streams and tables.

<a id="c3-download-selected-msgs-ksql"></a>

## Download selected messages

Download selected rows of messages in a JSON format. You can download messages
from the Messages browser in [Topics](topics/index.md#controlcenter-userguide-topics) or
[ksqlDB Editor](#controlcenter-userguide-ksql).

Run a query in the ksqlDB Editor to activate the message browser area. After
the messages area is populated with messages, you can select messages for
download, whether the query is running or stopped.

1. Select one or more contiguous or non-contiguous rows.
   ![Selected message for download in ksqlDB Editor browse messages pane](images/c3-ksql-download-records.png)
2. Select **JSON** and click **Download**. A file named `selected_data_<n>.json`
   that contains the selected messages in JSON format is downloaded into your
   downloads directory. The *n* represents the number of selected messages.

   Example filename:  `selected_data_1.json`

   Example contents:
   ```json
   [{"VIEWTIME":1611859623088,"USERID":"User_3","PAGEID":"Page_93"}]
   ```

<a id="c3-ksql-streams"></a>

## Streams

To access the Streams page, click the ksqlDB cluster name in the
[ksqlDB clusters page](#c3-ksql-clusters-page) and click the **Streams** tab.

Use the Streams page to:

- View a summary of streams for the ksqlDB cluster.
- Search for streams.
- View the Describe stream output (analogous to the [DESCRIBE](/platform/current/ksqldb/developer-guide/ksqldb-reference/describe.html#ksqldb-reference-describe)
  command in the ksqlDB CLI).
- Jump to the ksqlDB Editor page to query the stream.
- Drop a stream (analogous to the [DROP STREAM](/platform/current/ksqldb/developer-guide/ksqldb-reference/drop-stream.html#ksqldb-reference-drop-stream)
  command in the ksqlDB CLI).

![ksqlDB Streams page in Control Center](images/c3-ksql-streams-list.png)

Click a stream to view its information, like the stream name, associated Kafka
topic, number of partitions and replicas, and the data format.

![ksqlDB Inspect Stream page in Control Center](images/c3-ksql-stream-inspect.png)

<a id="c3-ksql-tables"></a>

## Tables

To access the Tables page, click the ksqlDB cluster name
in the [ksqlDB clusters page](#c3-ksql-clusters-page) and click the **Tables** tab.

Use the Tables page to:

- View a summary of tables for the ksqlDB cluster.
- Search for tables.
- View the Describe table output (analogous to the DESCRIBE|developer-guide/ksqldb-reference/describe/
  command in the ksqlDB CLI)
- Jump to the ksqlDB Editor page to query the table.
- Drop a table (analogous to the DROP TABLE|developer-guide/ksqldb-reference/drop-table/
  command in the ksqlDB CLI).

![The ksqlDB Tables page in Confluent Control Center](images/c3-ksql-tables-list.png)

Click a table to view its information, like the table name, associated Kafka
topic, number of partitions and replicas, and the data format.

![ksqlDB Inspect Table page in Confluent Control Center](images/c3-ksql-table-inspect.png)

<a id="c3-ksql-running-queries"></a>

## Persistent Queries

To see your running persistent queries, click the ksqlDB cluster name
in the [ksqlDB clusters page](#c3-ksql-clusters-page) and click the **Persistent Queries** tab.

Use the Persistent Queries page to:

- View the syntax and details of persistent queries.
- Search persistent queries.
- View the query execution plan by clicking **Explain** (analogous to the [EXPLAIN](/platform/current/ksqldb/developer-guide/ksqldb-reference/explain.html#ksqldb-reference-explain)
  command in the ksqlDB CLI).
- Terminate a persistent query.

![ksqlDB Persistent Queries page in Confluent Control Center](images/c3-ksql-running-queries.png)

## Flow View

To access the Flow View page, click the ksqlDB cluster name
in the [ksqlDB clusters page](#c3-ksql-clusters-page) and click the **Flow** tab.

Use Flow View to:

- View the topology of your ksqlDB cluster.
- Inspect the details of streams, tables, and the ksqlDB statements that
  create them.
- View events as they flow through your cluster.

![ksqlDB Flow View in Confluent Control Center](images/c3-ksql-flow-1.png)

Click a node in the graph to see details about the topology of your ksqlDB
cluster. For example, click on a stream to see its schema and the messages
as they arrive in realtime.

![ksqlDB Flow View in Control Center](images/c3-ksql-flow-2.png)

<a id="c3-enable-disable-ksql"></a>

## Enable and disable the ksqlDB feature in Control Center

The ksqlDB feature is enabled by default. The feature can be disabled by setting
the `confluent.controlcenter.ksql.enable` option in the Control Center properties
file to `false`. After disabling the feature, the ksqlDB submenu in the Cluster
navigation is no longer visible in the Control Center UI. You can disable the setting
if you are not using RBAC in Control Center or ksqlDB, and you do not want anyone
to access the ksqlDB feature.

#### IMPORTANT
If [RBAC](security/c3-rbac.md#c3-rbac-ksql) is enabled for Control Center,
it takes precedence over Access Control settings.

To disable the ksqlDB feature in Control Center:

1. Set the `confluent.controlcenter.ksql.enable` option in your
   `control-center.properties` file to `false`.
   ```bash
   ...
   confluent.controlcenter.ksql.enable=false
   ...
   ```

   #### NOTE
   Make the change in the appropriate Control Center properties files
   configured for your environments, including
   `control-center-dev.properties` or
   `control-center-production.properties`. The properties files are
   located in `/path-to-confluent/etc/confluent-control-center/`.
2. Restart Control Center and pass in the properties file for the configuration to
   take effect.
   - Local (dev) environment:

     #### IMPORTANT
     Do not use [confluent local](https://docs.confluent.io/confluent-cli/current/command-reference/local/index.html) for production use.

     ```bash
     confluent local services control-center stop
     confluent local services control-center start --config="../etc/confluent-control-center/control-center.properties"
     ```
   - Production environment:
     ```bash
     ./bin/control-center-stop
     ./bin/control-center-start ../etc/confluent-control-center/control-center.properties
     ```

To enable the feature again, set the option back to `true` and restart
Control Center with the updated properties file.

## Next Steps

- [Quick Start for Confluent Platform](/platform/current/get-started/platform-quickstart.html#quickstart)
