Kafka topics policies


Lenses gives the ability to tailor your topic management. You can enable or restrict users to perform different operations based on granular permissions based on namespaces.

Topic management 

There are different supported operations for the users like:

  • Create topics or allow for topic requests
  • Manage topic configurations
  • Add Partitions
  • Monitor, view metrics and add alerts

Read in Kafka Topics & Schemas

Topic settings 

In Lenses, you can allow users to create topics or topic requests. To help users follow your topic strategy, or prevent them from adding values that may be impacting your cluster, you can optionally add Topic Settings for important configurations. Additionally, you can enforce your topic naming strategy by adding rules on the pattern or custom regular expressions.

Lenses Kafka topic settings

Required permission 

Kafka Settings / ViewAdminEnables user to view topic settings, ACL’s and quotas
Kafka Settings / ManageAdminEnables user to edit topic settings, ACL’s and quotas

How it works 

Topic Settings are Lenses settings for Kafka Topics on top of your native Kafka topics configurations. The Topic Settings are empty by default, and they take precedence when Topic Creation is applied via Lenses UI/CLI/API/.

Under certain circumstances, the Topic Settings configured through Lenses might no longer be applicable. For instance, if you set a min replication factor of 3, but the number of active brokers in your Kafka cluster suddenly drops to 2, your settings will enter into an un-applicable state. When this happens, Lenses will lock all API calls around topic creation and configuration until this inconsistency is addressed. This can be done either by bringing the third broker back up, or by decreasing the minimum replication factor to 2.

Topic configuration rules 

Min PartitionsMin number of acceptable partitionYESMust be more or equal to 1
Max PartitionsMax number of acceptable partitionNOMust be more or equal to 1
Min ReplicationMin number of acceptable replication factorYESMust be more or equal to 1
Max ReplicationMax number of acceptable replication factorNOMust be more or equal to 1
Default RetentionTimeDefault time a Topic can retain dataNOMust be positive or -1(Infinite)
Max RetentionTimeMax alowed time a Topic can retain dataYESMust be positive or -1(Infinite)
Default RetentionSizeDefault size a Topic can retain dataNOMust be positive or -1(Infinite)
Max RetentionSizeMax alowed size a Topic can retain dataYESMust be positive or -1(Infinite)

Naming rules 

Naming PatternRegex to determine if a Topic name is allowedNO
Naming DescriptionDesription for the regex which appears to the Create form for the usersNO

Automate with CLI 

The following command can be used to retrieve the Topics Settings details. Output can be either JSON or YAML.

lenses-cli topic-settings --output="JSON"

Use the following command to update the topic settings policies:

lenses-cli topic-settings update \
    --partitions-min 1 --partitions-max 3 \
    --replication-min 1 --replication-max 2 \
    --retention-size-default -1 --retention-size-max -1 \
    --retention-time-default -1 --retention-time-max -1 \
    --naming-pattern="[a-zA-Z]*" --naming-description="Only letters ([a-zA-Z]*)"


To import or export topic settings policies:

lenses-cli export topic-settings --dir="DIRECTORY-PATH"
lenses-cli import topic-settings --dir="DIRECTORY-PATH"

Learn about the CLI


Can I specify a custom naming strategy? 

Under Topic Name, one can set the value of “Custom” for the characters allowed and provide their own regular expression string and description. The description will be used as a naming hint when creating new topics.

Topic name

What happens if I have set defaults on the Broker? 

Topic settings policies take precedence over Kafka Broker defaults. By default the policies are empty.