# Admin Configs API
The Admin Configs API manages the configuration settings of Kafka brokers, topics and consumer groups. It retrieves configuration details (`describe`) and applies incremental alterations (`alter`), for one resource or for many resources in one call.
!!! tip "Asynchronous Operation Propagation"
Many Kafka administrative operations (ACLs, configs, topics) are asynchronous in nature. When an API call returns successfully, this means the controller has accepted the request, not that the change has been fully propagated across the cluster. Configuration changes, ACL updates, and topic modifications may take several seconds to be applied on all brokers, depending on cluster size and network conditions. Always allow time for propagation and verify changes are applied across your cluster before proceeding with dependent operations.
!!! tip "Declarative Topics Feature For Topics Management"
The Admin Configs API provides low-level access for managing the configurations of Kafka topics, brokers and consumer groups. It requires detailed knowledge of individual settings. For topic configurations, we recommend the [declarative topics](Infrastructure-Declarative-Topics.md) feature instead.
## Admin Configs API / What are Kafka Configurations?
Kafka configurations are key-value pairs that define the behavior of brokers, topics and consumer groups.
## Admin Configs API / Types
The Karafka Admin Configs API involves several types that categorize the details of configuration management in Kafka. Understanding these types is crucial for effective configuration management.
### Admin Configs API / Types / Resource Types
The resource type tells which Kafka entity you configure: a topic, a broker or a consumer group.
| Type |
Description |
:topic |
Represents a single Kafka topic. |
:broker |
Represents a specific Kafka broker. |
:group |
Represents a single Kafka group, such as a consumer group. Use the group id as the resource name. |
### Admin Configs API / Types / Operation Types
Operations types within this API are used to specify the configuration changes being applied, such as setting or deleting values.
| Operation Type |
Description |
:set |
Sets or updates a configuration value. |
:delete |
Removes a configuration entry. |
:append |
Adds a value to a list-based configuration. |
:subtract |
Removes a value from a list-based configuration. |
### Admin Configs API / Types / Configuration Sources
Each configuration entry in `Resource#configs`, from `describe` and `alter`, has a `#source` that tells where its value comes from. Use it to tell a value set on the topic from one inherited from the broker or a built-in default. `#synonyms` lists all values that can set this configuration, in order of precedence and starting with the current value, for example the broker setting behind a topic setting. Each synonym has its own `#source`.
| Source |
Description |
:dynamic_topic_config |
Value set for this topic. |
:dynamic_broker_config |
Value set for a specific broker. |
:dynamic_default_broker_config |
Value set as the default for all brokers in the cluster. |
:static_broker_config |
Value from the broker properties at startup, for example from server.properties. |
:default_config |
Built-in default value. |
:consumer_group_config |
Value set for this consumer group. |
:unknown_config |
librdkafka does not report the source, or Karafka does not recognize it. |
### Admin Configs API / Types / Methods
| Method |
Description |
Arguments |
Returns |
Notes |
describe(*resources) |
Retrieves configurations for specified Kafka resources. |
resources - A single resource or an array of resources. |
An array of Resource objects with configuration details. |
Fetches configuration details in a single operation, even for multiple resources. |
alter(*resources) |
Applies configuration changes to specified Kafka resources using incremental updates. |
resources - A single resource or an array of resources. |
An array of Resource objects with the resulting configuration details (the same shape describe returns, not a separate confirmation object). |
This method is non-transactional and may succeed partially; validate configurations before applying. |
These methods provide an interface for detailed management of configurations in a Kafka environment, offering both retrieval and update functionalities.
## Admin Configs API / Usage
Here is how you might typically use the API to manage Kafka configurations:
```ruby
# Describe topic configurations
resource = Karafka::Admin::Configs::Resource.new(type: :topic, name: 'example')
topics = Karafka::Admin::Configs.describe(resource)
topics.each do |topic|
topic.configs.each do |config|
puts "#{topic.name} #{config.name}: #{config.value}"
end
end
# Show only the values set on the topic itself
topics.first.configs.select { |config| config.source == :dynamic_topic_config }.each do |config|
puts "#{config.name}: #{config.value}"
end
# Alter topic configurations
resource = Karafka::Admin::Configs::Resource.new(type: :topic, name: 'example')
# Set retention to 2 hours
resource.set('retention.ms', '7200000')
# Apply the changes
Karafka::Admin::Configs.alter(resource)
```
Consumer group configurations work the same way. With the [next-generation consumer group protocol (KIP-848)](https://karafka.io/docs/Kafka-New-Rebalance-Protocol.md), set the session and heartbeat timing for each consumer group with `consumer.session.timeout.ms` and `consumer.heartbeat.interval.ms`:
```ruby
# Describe consumer group configurations
resource = Karafka::Admin::Configs::Resource.new(type: :group, name: 'example_group')
groups = Karafka::Admin::Configs.describe(resource)
groups.each do |group|
group.configs.each do |config|
puts "#{group.name} #{config.name}: #{config.value}"
end
end
# Alter consumer group configurations
resource = Karafka::Admin::Configs::Resource.new(type: :group, name: 'example_group')
# Set the session timeout to 50 seconds
resource.set('consumer.session.timeout.ms', '50000')
# Apply the changes
Karafka::Admin::Configs.alter(resource)
```
## Admin Configs API / Example Use Cases
- **Configuration Audits**: Retrieve configurations to review and ensure compliance with operational standards.
- **Dynamic Configuration Tuning**: Adjust topic, broker or consumer group configurations.
- **Batch Configuration Management**: Update configurations for multiple brokers, topics or consumer groups in one call.
## Admin Configs API / See Also
- [Admin API](https://karafka.io/docs/Infrastructure-Admin-API.md) - General admin operations and topic management
- [librdkafka Configuration](https://karafka.io/docs/Librdkafka-Configuration.md) - Available librdkafka configuration options
---
*Last modified: 2026-11-26 19:42:16*