タイトルの通りですが、この場合、Telegraf をインストールしたサーバで
tail /var/log/telegraf/telegraf.log
とすると
2025-01-01T08:00:35Z E! [inputs.mongodb] Error in plugin: unable to connect to MongoDB: no reachable servers
などと出ます。結論から言うと Telegraf をバージョンアップすれば解決します。
ちなみに上記の問題が出た Telegraf のバージョンは telegraf-1.17.0-1.x86_64
でした。
Telegraf の更新、具体的には、CentOS7では以下。
yum update telegraf
ですが、
The GPG keys listed for the "InfluxDB Repository - RHEL 7" repository are already installed but they are not correct for this package.
と出て、バージョンアップできないことがあります。
その場合は、 /etc/yum.repos.d/influxdb.repo
を書き替えて、
gpgkey = https://repos.influxdata.com/influxdb.key
となっているところを
gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key
とし、
yum clean all
としたあと、 yum update telegraf
でうまく行くかと思います。
systemctl restart telegraf
をお忘れなく。
Telegraf をバージョンアップしたあと、ログにこんなエラーが出ることがあるようです。
2025-01-01T08:00:29Z E! [outputs.influxdb] When writing to [udp://xxx.xxx.xxx.xxx:8089] could not serialize metric: "xxxxxxxxxxxxxxxxxxxx": need more space
/etc/telegraf/telegraf.conf
の [[outputs.influxdb]]
下に
udp_payload = 10240
としたら治りました。10240はちょっと大きすぎかもしれないので、最初は1024とかから試してみてください。
以上