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

Fix kafka - add missing textformat setting #694

Merged
merged 3 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions docs/loggers/logger_kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Options:
* `mode` (string)
> Specifies the output format for Kafka messages. Output format: `text`, `json`, or `flat-json`.

* `text-format` (string)
> output text format, please refer to the default text format to see all available [directives](../configuration.md#custom-text-format), use this parameter if you want a specific format

* `buffer-size` (integer)
> Specifies the size of the buffer for DNS messages before they are sent to Kafka.

Expand Down Expand Up @@ -88,6 +91,7 @@ kafkaproducer:
sasl-username: false
sasl-password: false
mode: flat-json
text-format: ""
buffer-size: 100
topic: "dnscollector"
partition: 0
Expand Down
4 changes: 2 additions & 2 deletions loggers/kafkaproducer.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (k *KafkaProducer) AddDefaultRoute(wrk pkgutils.Worker) {
func (k *KafkaProducer) SetLoggers(loggers []pkgutils.Worker) {}

func (k *KafkaProducer) ReadConfig() {
if len(k.config.Loggers.RedisPub.TextFormat) > 0 {
k.textFormat = strings.Fields(k.config.Loggers.RedisPub.TextFormat)
if len(k.config.Loggers.KafkaProducer.TextFormat) > 0 {
k.textFormat = strings.Fields(k.config.Loggers.KafkaProducer.TextFormat)
} else {
k.textFormat = strings.Fields(k.config.Global.TextFormat)
}
Expand Down
2 changes: 2 additions & 0 deletions pkgconfig/loggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ type ConfigLoggers struct {
SaslPassword string `yaml:"sasl-password"`
SaslMechanism string `yaml:"sasl-mechanism"`
Mode string `yaml:"mode"`
TextFormat string `yaml:"text-format"`
BufferSize int `yaml:"buffer-size"`
FlushInterval int `yaml:"flush-interval"`
ConnectTimeout int `yaml:"connect-timeout"`
Expand Down Expand Up @@ -570,6 +571,7 @@ func (c *ConfigLoggers) SetDefault() {
c.KafkaProducer.SaslPassword = ""
c.KafkaProducer.SaslMechanism = SASLMechanismPlain
c.KafkaProducer.Mode = ModeFlatJSON
c.KafkaProducer.TextFormat = ""
c.KafkaProducer.BufferSize = 100
c.KafkaProducer.ConnectTimeout = 5
c.KafkaProducer.FlushInterval = 10
Expand Down
Loading