Search code examples
apache-kafkarsyslog

rsyslog write $programname as kafka topic


I want to write messages from rsyslog to kafka, use rsyslog $programname or $syslogtag as topic, however, omkafaka plugin didn't accept params, how can I achieve this?

I have tried using (type="omkafka" topic="$programname" ...), it fails.


Solution

  • I solved this by myself, omkafka 8.xx have a new property to accept dynamic topic, just config the property and add a template to inject dynamic topic.

    template(name="kafka_topic" type="string" string="%programname%")
    input(type="imtcp" port="10514")
    action(type="omkafka" topic="kafka_topic" dynatopic="on" dynatopic.cachesize="1000" template="msg_template" broker=["xxx", "xxx", "xxx", "xxx"])