Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(inputs.kafka_consumer): Option to set default fetch message bytes #11220

Merged
merged 8 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added oryxBuildBinary
Binary file not shown.
7 changes: 7 additions & 0 deletions plugins/inputs/kafka_consumer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ and use the old zookeeper connection method.
## '2 * max_processing_time'.
# max_processing_time = "100ms"

## The default number of message bytes to fetch from the broker in each
## request (default 1MB). This should be larger than the majority of
## your messages, or else the consumer will spend a lot of time
## negotiating sizes and not actually consuming. Similar to the JVM's
## `fetch.message.max.bytes`.
# fetch_message_bytes = 1048576
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please rename to consumer_fetch_default as this is what you ultimately use it as such.


## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
Expand Down
5 changes: 5 additions & 0 deletions plugins/inputs/kafka_consumer/kafka_consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type KafkaConsumer struct {
BalanceStrategy string `toml:"balance_strategy"`
Topics []string `toml:"topics"`
TopicTag string `toml:"topic_tag"`
FetchMessageBytes int32 `toml:"fetch_message_bytes"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making this a config.Size so you can specify human-readable sizes like 1MB or 1MiB?


kafka.ReadConfig

Expand Down Expand Up @@ -127,6 +128,10 @@ func (k *KafkaConsumer) Init() error {

cfg.Consumer.MaxProcessingTime = time.Duration(k.MaxProcessingTime)

if k.FetchMessageBytes != 0 {
cfg.Consumer.Fetch.Default = k.FetchMessageBytes
}

k.config = cfg
return nil
}
Expand Down