apache-kafkacollectd

Collectd and write_kafka plugin


I am trying to setup collectd to produce data for kafka using the write_kafka plugin. It works partially, meaning it creates the topic but fails to feed data in it. Here is the config file:

Hostname    "dummy"
FQDNLookup   false
Interval     60

LoadPlugin "logfile"
<Plugin "logfile">
  LogLevel "debug"
  File "/etc/collectd/collectd.log"
  Timestamp true
</Plugin>

LoadPlugin cpu
LoadPlugin df
LoadPlugin disk
LoadPlugin interface
LoadPlugin load
LoadPlugin memory
LoadPlugin netlink
LoadPlugin network
LoadPlugin sensors
LoadPlugin swap
LoadPlugin thermal

LoadPlugin "write_kafka"
<Plugin "write_kafka">
  Property "metadata.broker.list" "localhost:9092"
  <Topic "system">
    Format JSON
  </Topic>
</Plugin>

LoadPlugin csv
<Plugin "csv">
  DataDir "/etc/collectd/csv"
  StoreRates true
</Plugin>

Once run, on the kafka side I have a system-0 partition showing up which looks like the following:

ls -lash system-0/
total 12K
4.0K drwxr-xr-x 2 root root 4.0K Nov 19 12:30 .
4.0K drwxr-x--- 4 root root 4.0K Nov 19 12:33 ..
   0 -rw-r--r-- 1 root root  10M Nov 19 12:30 00000000000000000000.index
   0 -rw-r--r-- 1 root root    0 Nov 19 09:47 00000000000000000000.log
   0 -rw-r--r-- 1 root root  10M Nov 19 12:30 00000000000000000000.timeindex
4.0K -rw-r--r-- 1 root root    8 Nov 19 12:30 leader-epoch-checkpoint

where one can see that the log file is empty.

Here is the log:

[2019-11-19 10:46:00] plugin_load: plugin "cpu" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "df" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "disk" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "interface" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "load" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "memory" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "netlink" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "network" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "sensors" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "swap" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "thermal" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "cpu" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "df" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "disk" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "interface" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "load" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "memory" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "netlink" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "network" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "sensors" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "swap" successfully loaded.
[2019-11-19 10:46:00] plugin_load: plugin "thermal" successfully loaded.
[2019-11-19 10:46:00] Systemd detected, trying to signal readyness.
[2019-11-19 10:46:00] Initialization complete, entering read-loop.
[2019-11-19 10:46:00] write_kafka plugin: created KAFKA handle : rdkafka#producer-1
[2019-11-19 10:46:00] write_kafka plugin: handle created for topic : system
[2019-11-19 10:46:00] [thrd:2997bc280c89:9092/0]: 2997bc280c89:9092/0: Failed to resolve '2997bc280c89:9092': Name or service not known
[2019-11-19 10:46:00] [thrd:2997bc280c89:9092/0]: 2997bc280c89:9092/0: Failed to resolve '2997bc280c89:9092': Name or service not known

Any clue?


Solution

  • The Kafka configuration was not properly set. We needed to advertise listeners by setting the advertised.listeners to PLAINTEXT://HOSTNAME:9092.