Skip to content

Commit

Permalink
Fix kafka - add missing textformat setting (#694)
Browse files Browse the repository at this point in the history
* fix read config
* add missing textformat option
* update docs
  • Loading branch information
dmachard authored May 5, 2024
1 parent 8a66ba7 commit 25b9b58
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit 25b9b58

Please sign in to comment.