Use Telegraf to get metrics from Raspberry Pi

Greetings. I have my InfluxDB v2.3 running on my LAN at 192.168.7.11. Woo hoo!

I have a Raspbery Pi on the LAN at 192.168.7.44 and I installed Telegraf on the Pi so that I can monitor the Pi’s metrics in Influx. There are many posts about this, but I thought this one seemed the best:

I followed the instructions and I got nothing! Let me recap the basics and maybe something will jump out for you readers as to something I missed…

  1. Installed telegraf using sudo apt-get update && sudo apt-get install telegraf and everything went smoothly to end up with 1.24.1
  2. telegraf.conf file is located in /etc/telegraf
  3. the only things I changed in telegraf.conf were:
# # Configuration for sending metrics to InfluxDB 2.0
# [[outputs.influxdb_v2]]
#   ## The URLs of the InfluxDB cluster nodes.
#   ##
#   ## Multiple URLs can be specified for a single cluster, only ONE of the
#   ## urls will be written to each interval.
#   ##   ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
urls = ["http://192.168.7.11:8086"]
#
#   ## Token for authentication.
token = "---my token here, but kept from prying eyes---"
#
#   ## Organization is the name of the organization you wish to write to.
organization = "h1-org"
#
#   ## Destination bucket to write into.
bucket = "rasp-pi"
#
#   ## The value of this tag will be used to determine the bucket.  If this
#   ## tag is not set the 'bucket' option is used as the default.
  1. I entered the command systemctl start telegraf and it asked me for the password of the Rasbperry Pi, which I successfully entered and it said ==== AUTHENTICATION COMPLETE ===
  2. I got nothing on the Influx dashboard (bucket: rasp-pi), so I typed sudo service telegraf start into the terminal window and still get nothing in Influx.

Since I am actively populating other buckets in Influx for many months now and have loads of data that I can view, query, etc., I can definitely say Influx is set up fine. The problem seems that Telegraf is not sending out the data. What did I miss?

Greetings. I have my InfluxDB v2.3 running on my LAN at 192.168.7.11. Woo
hoo!

Have you confirmed (eg: with “netstat -lptn”) that it is listening on that IP
address, port 8086 (and not perhaps only listening on localhost 127.0.0.1)?

  1. the only things I changed in telegraf.conf were:

# Configuration for sending metrics to InfluxDB 2.0

[[outputs.influxdb_v2]]

Have you genuinely left that line commented out (by the # at the start)?

If so, I suggest deleting the #, try again, and report back here :slight_smile:

Antony.

Similar to the above, I would check your logs from the Telegraf service to get a better idea of what might be erroring out. It could be a config file mistake or something else.

journalctl --follow --unit=telegraf

OK, I missed removing the # as @Pooh pointed out, but even with that line now commented out, I still get no data.

I do not have command line access to the Influx machine (192.168.7.11) until tomorrow, so cannot check that it is listening on that IP address.

However, do I need to start Telegraf on the above machine? EDIT: I tried running this command on the Pi, and it says “Error getting HTTP config”, so clearly it is intended for the Influx machine. I will do that on Saturday.

gives the following:

Sep 23 21:39:13 raspberrypi telegraf[18983]: 2022-09-24T01:39:13Z E! [agent] Error writing to outputs.influxdb: could not write any address
Sep 23 21:39:23 raspberrypi telegraf[18983]: 2022-09-24T01:39:23Z W! [outputs.influxdb] Metric buffer overflow; 18 metrics have been dropped
Sep 23 21:39:23 raspberrypi telegraf[18983]: 2022-09-24T01:39:23Z E! [outputs.influxdb] When writing to [http://localhost:8086]: failed doing req: Post "http://localhost:8086/write?db=telegraf": dial tcp [::1]:8086: connect: connection refused

Is the problem with the Pi not being able to send out the metrics, or with the Influx machine not being able to accept them?

EDIT: Answering my own question, the message returned above seems clear enough:

> dial tcp [::1]:8086: connect: connection refused