4.3

You are viewing documentation for an older version of Lenses.io View latest documentation here

Kafka topics

The CLI can view, create and modify topics.

View all topics 

The optional names flag wil display only the names of the topics, and if –unwrap then each topic name will be displayed on a new line as a simple text

lenses-cli topics [--names [--unwrap]]

View a specific topic 

lenses-cli topic --name=reddit_posts

Create topics 

lenses-cli topic create \
    --name="topicName" \
    --replication=1 \
    --partitions=1 \
    --configs="{\"max.message.bytes\": \"1000010\"}"

Update from a file:

lenses-cli topic create ./topic.yml

Example file:

name: topicName
replication: 1
partitions: 1
configs:
  max.message.bytes: "1000010"

Update a topic’s configuration 

lenses-cli topic update \
    --name="topic2" \
    --configs="{\"max.message.bytes\": \"1000020\"}"

Update from a file:

lenses-cli topic update ./topic.yaml

Example file:

name: topicName
replication: 1
partitions: 1
configs:
  max.message.bytes: "1000010"

Update a topic’s metadata configuration 

# first change the key/value type
lenses-cli topics metadata set \
    --name=topicName \
    --key-type=bytes \
    --value-type=xml

# now you may change its schema
lenses-cli topics metadata set \
    --name=topicName \
    --key-type=bytes \
    --key-schema="{\"type\":\"record\",\"name\":\"lenses_record\",\"namespace\":\"lenses\",\"fields\":[{\"name\":\"keyField\",\"type\":\"string\"}]}" \
    --value-type=xml \
    --value-schema="{\"type\":\"record\",\"name\":\"lenses_record\",\"namespace\":\"lenses\",\"fields\":[{\"name\":\"valueField\",\"type\":\"string\"}]}"

Update from a file:

lenses-cli topic update ./topic.yaml

Example file:

topicName: topicName
keyType: bytes
valueType: xml
valueSchema: "{\"type\":\"record\",\"name\":\"lenses_record\",\"namespace\":\"lenses\",\"fields\":[{\"name\":\"heading3\",\"type\":\"string\"}]}"

Delete topics 

lenses-cli topic delete --name="topic2"