Enforce topic naming, sizing, and retention conventionsv1.3+
This Request Rule Validator policy enforces topic conventions for a shared Kafka cluster.
In this example:
- Topic names must start with
team-a.. - Topics can’t have more than 50 partitions.
- Topics must have a replication factor of at least 3.
retention.msmust be set to 24 hours (86400000).
Clients can change a topic after they create it, so the policy enforces the conventions on more than one request type:
create_topics: Enforces all the conventions when a client creates a topic. If the request uses a manual replica assignment, the partition count and replication factor are-1, so the rules checkcontext.topic.assignmentsinstead.create_partitions: Prevents clients from growing a topic past 50 partitions.alter_configs: This request replaces the full configuration of a topic, so it must includeretention.mswith the required value. Otherwise,retention.msgoes back to the broker default.incremental_alter_configs: Clients can changeretention.msonly with theSEToperation and the required value. This rule also prevents clients from deletingretention.ms.
Each rule’s expression describes the request state that’s allowed.
When an item in the request, for example a topic, doesn’t match a rule, Event Gateway rejects only that item with the Kafka POLICY_VIOLATION error code.
Other items in the same batched request are still processed.