Telegraf net_response for UDP target does not return values

Hello,

I use a Node MCU (arduino-like device) to collect some measurements and I send them to Telegraf and then to influxDB and finally plot them in Grafana. It works fine. What I’m trying to do is to use the net_response input plugin in Telegraf via UDP and send a dummy message to the MCU and measure the response time. The MCU is programmed to listen and reply to UDP messages with an “ACK” message.

In the Telegraf side the configuration looks like this:

[[inputs.net_response]]
   protocol = "udp"
   address = "192.168.178.28:4210"
    timeout = "1s"
    read_timeout = "1s"
    send = "THIS IS TELEGRAF!"
    expect = "ACK"
    fielddrop = ["result_type", "string_found"]
[[inputs.socket_listener]]
    service_address = "udp://:1891"

where 192.168.178.28 is the IP of the MCU and 4210 is the UDP port that the MCU listens to. Telegraf sends out the message “THIS IS TELEGRAF!” and I can see it coming in the serial monitor for the MCU. The MCU replies with an “ACK” (I’ve tested that it reaches my PC where Telegraf runs via netcat) and replies to port 1891 where Telegraf listens to. However I get only the error_responce code in influxDB, so I suspect that the “ACK” message is not parsed correctly by Telegraf. When checking the telegraf.service I get

2020-05-17T11:06:38Z W! [agent] [inputs.net_response] did not complete within its interval
2020-05-17T11:06:42Z E! [inputs.socket_listener] Unable to parse incoming packet: invalid character 'A' looking for beginning of value

Is there something wrong with the setup or perhaps with the encoding of the ACK message?

Some updates. I enabled a second instance of the [[inputs.socket_listener]]to listen to a different UDP port dedicated to the ACK messages:

[[inputs.net_response]]
   protocol = "udp"
   address = "192.168.178.28:4210"
    timeout = "1s"
    read_timeout = "1s"
    send = "THIS IS TELEGRAF!"
    expect = "ACK"
    fielddrop = ["result_type", "string_found"]

[[inputs.socket_listener]]
    service_address = "udp://:1891"
    data_format = "json"
    json_query = ""
    name_override = "meas_ext"
    tag_keys = ["deviceID"]
    json_name_key = ""
    json_time_key = ""
    json_time_format = ""

[[inputs.socket_listener]]
   service_address = "udp://:4211"
   data_format = "value"
   data_type = "string"
   name_override = "ack"

Now the messages for not being able to parse the first character ‘A’ is gone but still no metrics.

Please close the topic. I modified my Arduino code to respond to the port that the incoming message arrives from and deleted the socket_listener for the extra udp port as it is not needed. Now it works fine.

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.