CDC for Astra DB
CDC for Astra DB automatically captures changes in real time, de-duplicates the changes, and streams the clean set of changed data into Astra Streaming where it can be processed by client applications or sent to downstream systems.
Astra Streaming processes data changes via a Pulsar topic. By design, the Astra Streaming Change Data Capture (CDC) component is simple, with a 1:1 correspondence between the table and a single Pulsar topic.
This doc will show you how to create a CDC connector for your Astra DB deployment and send change data to an Elasticsearch sink.
Enabling CDC for Astra DB will result in increased costs based on your Astra Streaming usage. See Pricing. |
Supported data structures
The following Cassandra CQL 3.x data types (with the associated AVRO type or logical-type) are supported for CDC for Astra DB:
-
ascii (string)
-
bigint (long)
-
blob (bytes)
-
boolean (boolean)
-
counter (counter)
-
date (date)
-
decimal (cql_decimal)
-
double (double)
-
float (float)
-
inet (string)
-
int (int)
-
smallint (int)
-
text (string)
-
timeuuid (uuid)
-
tinyint (int)
-
uuid (uuid)
-
varchar (string)
-
varint (cql_varint)
Cassandra static columns are supported:
-
On row-level updates, static columns are included in the message value.
-
On partition-level updates, the clustering keys are null in the message key. The message value only has static columns on
INSERT
/UPDATE
operations.
For columns using data types that are not supported, the data types are omitted from the events sent to the data topic. If a row update contains both supported and unsupported data types, the event will include only columns with supported data types.
AVRO interpretation
Astra DB keys are strings, while CDC produces AVRO messages which are structures. The conversion for some AVRO structures requires additional tooling that can result in unexpected output.
The table below describes the conversion of AVRO logical types. The record
type is a schema containing the listed fields.
Name | AVRO type | Fields | Explanation |
---|---|---|---|
collections |
array |
lists, sets |
Sets and Lists are treated as AVRO type |
decimal |
record |
BIG_INT, DECIMAL_SCALE |
The Cassandra DECIMAL type is converted to a |
duration |
record |
CQL_DURATION_MONTHS, CQL_DURATION_DAYS, CQL_DURATION_NANOSECONDS |
The Cassandra DURATION type is converted to a |
maps |
map |
The Cassandra MAP type is converted to the AVRO map type, but the keys are converted to strings. |
Limitations
CDC for Astra DB has the following limitations:
-
Does not manage table truncates.
-
Does not sync data available before starting the CDC agent.
-
Does not replay logged batches.
-
Does not manage time-to-live.
-
Does not support range deletes.
-
CQL column names must not match a Pulsar primitive type name (ex: INT32).
-
Does not support multi-region.
Creating a tenant and a topic
-
In astra.datastax.com, select Create Streaming.
-
Enter the name for your new streaming tenant and select a provider.
-
Select Create Tenant.
Use the default persistent and non-partitioned topic.
Astra DB CDC can only be used in a region that supports both Astra Streaming and Astra DB. See Regions for more information. |
Creating a table
-
In your database, create a table with a primary key column:
CREATE TABLE IF NOT EXISTS <keyspacename>.tbl1 (key text PRIMARY KEY, c1 text);
-
Confirm you created your table:
select * from <mykeyspace>.tbl1;
Results:
Connecting to CDC for Astra DB
-
Select the CDC tab in your database dashboard.
-
Select Enable CDC.
-
Complete the fields to connect CDC.
-
Select Enable CDC. Once created, your CDC connector will appear:

Connecting Elasticsearch sink
Once you have created your CDC connector, connect an Elasticsearch sink to it. DataStax recommends using the default Astra DB settings.
-
Select Add Elastic Search Sink from the database CDC console to enforce the default settings.
-
Use your Elasticsearch deployment to complete the fields.
To find your Elasticsearch URL, navigate to your deployment within the Elastic Common Schema (ECS). Copy the Elasticsearch endpoint to the Elastic Search URL field.
-
Complete the remaining fields.
Most values will auto-populate. These values are recommended:
-
ignoreKey
asfalse
-
nullValueAction
asDELETE
-
schemaEnable
astrue
-
-
When the fields are completed, select Create.
If creation is successful, <sink-name> created successfully
will print at the top of the screen. You can confirm your new sink was created in the Sinks tab.

Sending messages
Let’s process some changes with CDC.
-
Go to the CQL console.
-
Modify the table you created.
INSERT INTO <keyspacename>.tbl1 (key,c1) VALUES ('32a','bob3123'); INSERT INTO <keyspacename>.tbl1 (key,c1) VALUES ('32b','bob3123b');
-
Confirm the changes you’ve made:
select * from <keyspacename>.tbl1;
Results:
Confirming ECS is receiving data
To confirm ECS is receiving your CDC changes, use a curl
request to your ECS deployment.
-
Get your index name from your ECS sink tab:
-
Issue your
curl
request with your Elasticusername
,password
, andindex name
:curl -u <username>:<password> \ -XGET "https://asdev.es.westus2.azure.elastic-cloud.com:9243/<index_name>.tbl1/_search?pretty=true" \ -H 'Content-Type: application/json'
If you have a trial account, the username is
elastic
.
You will receive a JSON response with your changes to the index, which confirms Astra Streaming is sending your CDC changes to your ECS sink.
{
"_index" : "index.tbl1",
"_type" : "_doc",
"_id" : "32a",
"_score" : 1.0,
"_source" : {
"c1" : "bob3123"
}
}
{
"_index" : "index.tbl1",
"_type" : "_doc",
"_id" : "32b",
"_score" : 1.0,
"_source" : {
"c1" : "bob3123b"
}
}