KSQL¶
Control Center provides the convenience of running streaming queries on one or more KSQL clusters within its graphical user interface. The KSQL feature is enabled by default in Control Center.
Important
If RBAC is enabled, the ability to view and use KSQL in Control Center is determined by the assigned roles and associated privileges configured in both KSQL and Control Center.
For more information about KSQL, see KSQL.
Tip
Go through the Confluent Platform Local or Docker quick start guides for a fast set up of streams, tables, and persisted running queries in Control Center.
Configure Control Center for KSQL clusters¶
When you start a local Confluent Platform install using the confluent local start command from the Confluent CLI, a default KSQL cluster named KSQL is created for you.
To configure Control Center to communicate with your own multiple KSQL
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 KSQL clusters. For more information, see the KSQL Settings options in the Control Center Configuration Reference.
Important
Be sure to review Integrate KSQL with Confluent Control Center for more information on configurations for both KSQL and Control Center.
Click Learn More for information on Installing KSQL.
Links to comprehensive KSQL documentation are available throughout the Control Center KSQL web interface.
KSQL clusters page¶
To access the KSQL clusters page, click the cluster from the navigation bar and select KSQL from the cluster submenu.
Use the KSQL clusters page to:
- View a summary of all KSQL clusters connected to Control Center.
- Search for a KSQL cluster being managed by the Control Center instance.
- Browse topic messages.
- Navigate to the KSQL Editor, Streams, Tables, and Running Queries for each KSQL cluster. Click the KSQL cluster name link to navigate to the KSQL Editor and other pages.
View the number of running queries, registered streams, and registered tables for each KSQL cluster.
KSQL Editor¶
To access the KSQL Editor page, click the KSQL cluster name in the KSQL clusters page.
Use the KSQL Editor page to run KSQL queries and browse messages.
After creating streams and tables, the resizeable streams and tables pane becomes 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:
- Tables are indicated with an orange Tb expandable node:
Click a node to view the schema for a stream or table.
A Search box is available for you to search for streams and tables.
Click the documentation links for more KSQL information.
Download selected messages¶
Download selected rows of messages in a JSON format. You can download messages from the Messages browser in Topics or KSQL Editor. Run a query in the KSQL Editor to activate the message browser area. After the messages area becomes populated with messages, you can select messages for download whether the query is running or stopped.
Select one or more contiguous or non-contiguous rows. The Download button becomes available and shows the number of selected messages.
Tip
Press the command key + click to select non-contiguous rows. Press shift + click on a beginning and ending row to select a contiguous range of messages.
Click Download (n). 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:
[{"ROWTIME":1562939957397,"ROWKEY":"6578171","VIEWTIME":6578171,"USERID":"User_6","PAGEID":"Page_85"}]
Streams¶
To access the Streams page, click the KSQL cluster name in the KSQL clusters page and click the Streams tab.
Use the Streams page to:
- View a summary of streams for the KSQL cluster.
- Search for streams.
- Add a stream.
- View the Describe stream output (analogous to the DESCRIBE command in the KSQL CLI).
- Jump to the KSQL Editor page to query the stream.
- Drop a stream (analogous to the DROP command in the KSQL CLI).
View information such as the stream name, associated Kafka topic and its number of partitions and replicas, and the data format for existing streams.
Tables¶
To access the Tables page, click the KSQL cluster name in the KSQL clusters page and click the Tables tab.
Use the Tables page to:
- View a summary of tables for the KSQL cluster.
- Search for tables.
- Add a table.
- View the Describe table output (analogous to the DESCRIBE command in the KSQL CLI)
- Jump to the KSQL Editor page to query the table.
- Drop a table (analogous to the DROP command in the KSQL CLI).
Click Learn More to view the KSQL recipes available in the Stream Processing Cookbook.
View information such as the table name, associated Kafka topic and its number of partitions and replicas, and the data format for existing tables.
Running Queries¶
To access the Running Queries page, click the KSQL cluster name in the KSQL clusters page and click the Running Queries tab.
Use the Running Queries page to:
- View the syntax and details of running queries.
- Search running queries.
- View the query execution plan by clicking Explain (analogous to the EXPLAIN command in the KSQL CLI).
- Terminate a running query.
Click Persistent Query Examples to view the KSQL recipes available in the Stream Processing Cookbook.
Enable and disable the KSQL feature in Control Center¶
The KSQL 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 KSQL 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 KSQL, and you do not want
anyone to access the KSQL feature.
Important
If RBAC is enabled for Control Center, it takes precedence over Access Control settings.
To disable the KSQL feature in Control Center:
Set the
confluent.controlcenter.ksql.enable
option in yourcontrol-center.properties
file tofalse
.... 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
orcontrol-center-production.properties
. The properties files are located in/path-to-confluent/etc/confluent-control-center/
.Restart Control Center and pass in the properties file for the configuration to take effect.
Local (dev) environment:
Important
Do not use confluent local for production use.
confluent local stop --path <path-to-confluent> confluent local start --path <path-to-confluent> ../etc/confluent-control-center/control-center.properties
Production environment:
./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.