Observing Error in plugin: metric parse error: while executing the telegraf

23 Views Asked by At

Observing following error While Executing the telegraf to send data from telegraf to influx db.

confg file data is correct, any idea why this error ? how to fix this?

**2024-03-20T13:09:10Z E! [inputs.exec] Error in plugin: metric parse error: expected field at 1:13: "HTTP/1.1 204 No Content" 2024-03-20T13:09:19Z E! [inputs.exec] Error in plugin: metric parse error: expected field at 1:13: "HTTP/1.1 204 No Content" 2024-03-20T13:10:01Z E! [inputs.exec] Error in plugin: exec: command timed out for command "/root/udp3.sh": % Total % Received % Xferd Average Spee 2024-03-20T13:09:30Z E! [inputs.exec] Error in plugin: exec: command timed out for command "/root/tcp3.sh": % Total % Received % Xferd Average Spee> **

I suspect for the metric error "Im having the syntax like this in the script

curl -i -XPOST 'http://150.240.76.167:8086/write?db=staging' --data-binary "$measurement_name,host=$host,sender_bitrate=sender_bitrate sender_bitrate=$sender_bitrate $timestamp"

can someone check this once or correct it ?

1

There are 1 best solutions below

0
powersj On

The exec plugin exists to run arbitrary commands, which then return metrics for telegraf to parse and generate metrics. The errors you are seeing are stating that the plugin cannot parse the resulting output successfully.

By default, the plugin expects metrics in the format of line protocol like:

metric,host=foo value=42 1234567890

But that can be changed via the data_format option to one of the supported parsers. That explains the metric parse errors.

The timeout errors are, as they imply, the command taking too long.

If you want to send metrics or data to InfluxDB, then I would suggest one of the following:

  • wrap your curl command in a script and return an actual metric
  • use a cron job or other scheduler to run your script, as your current use-case is not making full use of telegraf
  • use the influxdb or influxdb_v2 outputs in telegraf and return an actual metric
  • use the influxdb client libraries to write code to send your metrics in your favorite programming language instead