I thought that the json format could the problem but if I replace the inputs.exec with a simple cat /tmp/speedtest.json of a json saved from the command ran manually, it works as expected and all the json values are published to the influxdb output
Any idea why is telegraf reporting that the command exits with a 1 status or how could I debug more?
I think this is probably due to the shell pipeline in the command, if you want to use these types of constructs you need to run the command in a shell explicitly:
commands = ['sh -c "echo foo bar=1 | cat"']
I do find it a bit easier to parse this command using the --csv flag, here is what I have been doing:
Hi,
sorry for the late answer. I eventually found out the it was indeed the command itself that was failing.
sudo -u telegraf /usr/bin/speedtest worked fine but not
sudo su - telegraf
/usr/bin/speedtest
The speedtest commands is looking for a file in ~/.config/ookla/speedtest-cli.json that was not present.
Now for the telegraf part, I believe it would be really helpful to see the error output in the telegraf logs when the command fails. It would have saved me quite some time.
I am hitting the same problem but I run the docker image of telegraf. I can manually execute the speedtest binary, but for some reason telegraf isn’t running it.
Getting the same problem as the previous persons. I can run the whole /usr/bin/speedtest -f json-pretty from outside of my docker container using either the root or telegraf user. I’ve giving and created the correct .config folders inside of the container. It returns JSON string without issue. But if Telegraf runs this then it returns with exit code 1.
It would be nice to get more debug data on what’s been output when the error occurs.