My interpretation of the output plugin is it is making a sendmessage call for each individual metric, but I what I can be sure is if there is any way to govern how the underlying Kafka producer batches these. I am getting the impression we are getting an individual call per metric to our Kafka brokers.
func (k *Kafka) Write(metrics []telegraf.Metric) error {
if len(metrics) == 0 {
return nil
}
for _, metric := range metrics {
buf, err := k.serializer.Serialize(metric)
if err != nil {
return err
}
topicName := k.GetTopicName(metric)
m := &sarama.ProducerMessage{
Topic: topicName,
Value: sarama.ByteEncoder(buf),
}
if h, ok := metric.Tags()[k.RoutingTag]; ok {
m.Key = sarama.StringEncoder(h)
}
_, _, err = k.producer.SendMessage(m)
if err != nil {
return fmt.Errorf("FAILED to send kafka message: %s\n", err)
}
}
return nil
}```