Help using socket_listener telegraf input plugin

Hi,

I have a WiFi module sending sensor data (every 1 second) from an Arduino Via UDP to a my RPi where I’m running an instance of Telegraf. I’ve setup the socket_listener input in the telegraf config.

The Arduino seems to be sending the UDP packets fine.

Telegraf says:

[inputs socket_listener] Listening on udp://[: :]:8888

I’m expecting to see data coming through, but I don’t see anything in the window.

Also when I query the influx database that its supposed to be writing to there are no results.

Be great if anyone on here has any pointers please?

Thanks,

Q

Hi,

Can you share your telegraf config?

Have you tried setting debug=true in the agent part of your config?

Or writing data to stdout using [[outputs.file]] and sharing the response:

[[outputs.file]]
  files = ["stdout"]

Hey, thanks for the reply & the recommendations - I’ve implemented these into the config file which I’ve attached.

Another thing I’ve tried using Netcat to manually send some data via udp to the port I’m listening on:

nc -u localhost 8888
weather temperature=21

This appears to come through to Telegraf and parsed into Influxdb just fine.

My Arduino appears to be sending data to the same port via WiFi once a second, but I still see no output in Telegraf - see attached output.

Still not sure why the data is not getting through?

telegraf_config.txt (16.5 KB) telegraf_output.txt (1.4 KB)

Hi,

Thanks for sharing that. Your output is showing that it’s not writing any metrics but I’m not sure why.

I used a similar config and did the basic example in this tutorial Telegraf Socket Listener Input Plugin | InfluxData and it wrote metrics both to Influxdb and stdout.

My config:

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  debug = true
  quiet = false
  omit_hostname = true

[[inputs.socket_listener]]
  service_address = "udp://:8094"
  data_format = "influx"


[[outputs.influxdb]]
   urls = ["http://127.0.0.1:8086"]
   database = "arduino"

[[outputs.file]]
   files=["stdout"]

Part of output:

2020-12-22T15:17:31Z I! [inputs.socket_listener] Listening on udp://[::]:8094
2020-12-22T15:17:41Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2020-12-22T15:17:41Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
m1,tag1=tag_value value=1 1608650261877235000
2020-12-22T15:17:51Z D! [outputs.file] Wrote batch of 1 metrics in 172.952µs
2020-12-22T15:17:51Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2020-12-22T15:17:51Z D! [outputs.influxdb] Wrote batch of 1 metrics in 269.373064ms
2020-12-22T15:17:51Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics

Within the ReadMe there is also notes about buffer_sizes when using UDP which could also be something to look at telegraf/plugins/inputs/socket_listener at master · influxdata/telegraf · GitHub.

Let me know if that helps you at all.

Hi,

Thanks for giving it a go. Seems I can get similar results using nc, but still nothing from my arduino.

I had also implemented the change Re: buffer size,

net.core.rmem_max=8388608
net.core.rmem_default=8388608

This is now default, but it didn’t fix the issue unfortunately.

FYI I also have a similar post on Arduino forum to look at that side of it.

I guess the main difference from the Socket Listener example (in my case at least) is nc is using wired ethernet and the Arduino is using WiFi. Maybe some udp testing over WiFi. Could be some setting on my router maybe.