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

Added MaxOpenRequests to kafka output config #42515

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]


*Filebeat*

- Added MaxOpenRequests to kafka output config {pull}42515[42515]
flexitrev marked this conversation as resolved.
Show resolved Hide resolved
- Convert netflow input to API v2 and disable event normalisation {pull}37901[37901]
- Removed deprecated Squid from Beats. See <<migrate-from-deprecated-module>> for migration options. {pull}38037[38037]
- Removed deprecated Sonicwall from Beats. Use the https://docs.elastic.co/integrations/sonicwall[SonicWall Firewall] Elastic integration instead. {pull}38037[38037]
Expand Down
3 changes: 3 additions & 0 deletions libbeat/outputs/kafka/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type kafkaConfig struct {
BulkFlushFrequency time.Duration `config:"bulk_flush_frequency"`
MaxRetries int `config:"max_retries" validate:"min=-1,nonzero"`
Headers []header `config:"headers"`
MaxOpenRequests int `config:"max_open_requests" validate:"min=1"`
Backoff backoffConfig `config:"backoff"`
ClientID string `config:"client_id"`
ChanBufferSize int `config:"channel_buffer_size" validate:"min=1"`
Expand Down Expand Up @@ -137,6 +138,7 @@ func defaultConfig() kafkaConfig {
CompressionLevel: 4,
Version: kafka.Version("2.1.0"),
MaxRetries: 3,
MaxOpenRequests: 5,
flexitrev marked this conversation as resolved.
Show resolved Hide resolved
Headers: nil,
Backoff: backoffConfig{
Init: 1 * time.Second,
Expand Down Expand Up @@ -211,6 +213,7 @@ func newSaramaConfig(log *logp.Logger, config *kafkaConfig) (*sarama.Config, err
k.Net.ReadTimeout = timeout
k.Net.WriteTimeout = timeout
k.Net.KeepAlive = config.KeepAlive
k.Net.MaxOpenRequests = config.MaxOpenRequests
k.Producer.Timeout = config.BrokerTimeout
k.Producer.CompressionLevel = config.CompressionLevel

Expand Down
4 changes: 4 additions & 0 deletions libbeat/outputs/kafka/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func TestConfigAcceptValid(t *testing.T) {
"realm": "ELASTIC",
},
},
"set max requests": mapstr.M{
"topic": "tomato",
"max_open_requests": 50,
},
}

for name, test := range tests {
Expand Down
9 changes: 9 additions & 0 deletions libbeat/outputs/kafka/docs/kafka.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,15 @@ Set `max_retries` to a value less than 0 to retry until all events are published
The default is 3.
endif::[]

===== `max_open_requests`

The maximum number of unacknowledged requests the client will send on a single connection before blocking.
Throughput can improve but message ordering is not guaranteed if Idempotent is disabled, see:
Copy link
Contributor

Choose a reason for hiding this comment

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

we dont expose idempotent as a setting and the default value for this also impacts message ordering so I think we can get rid of the comment about idempotent and message ordering?

Copy link
Author

Choose a reason for hiding this comment

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

Removed reference to idempotent, but I think it's worth keeping the note about the impact on message ordering. If we aren't explicit about the lack of guarantee, it will be easy for someone to get the wrong idea

https://kafka.apache.org/protocol#protocol_network
https://kafka.apache.org/28/documentation.html#producerconfigs_max.in.flight.requests.per.connection

The default is 5.

===== `backoff.init`

The number of seconds to wait before trying to republish to Kafka
Expand Down
Loading