Inputs.exec plugin for Python script

Hello,

I want to use the inputs.exec plugin to send data from my python script to our monitoring platform via telegraf. I have created the following inputs.exec.conf file in telegraf.d

[[inputs.exec]]
commands = ["/usr/bin/python /home/user/xyz_api.py"]
timeout = “5s”
data_format = “json”

However I’m not able to see the data in our monitoring platform Wavefront. I’m new to telegraf so still learning of troubleshooting steps here

My sample output is something like this
Metric = ('xyz.{}.{} 2 source=xyz '.format(RoomName, ‘RoomStatus’))

Please note:
sudo -u telegraf /usr/bin/python3.6 /home/xyz/xyz_api.py executes successfully

not sure if Json data format is appropriate data format here but since I’m getting the response from the rest api I’m using in this script in json format I have used json as the data format

Suggestions would be appreciated

Can you provide the full telegraf config in a </> code block , redacting any sensitive bits.

I assume that’s python code. Can you provide a couple of real output lines, anonymising if you need to.

“org.api.RoomName.RoomStatus 0 source=app_api_integration”

this is a single snippet of output line that is being send to our monitoring platform Wavefront. 177 such lines are sent when we execute the python code.

I was checking the sudo systemctl status telegraf.service and it gave this error
[inputs.exec] Error in plugin: exec: Command timed out. for command ‘/usr/bin/python3.6 /home/xyz/abc.py’

so I increased the timeout to 5m then later it gave this error
[agent] [inputs.exec] did not complete within its interval

Is there an error with .conf file or the command parameter here
commands = ["/usr/bin/python3.6 /home/xyz/abc.py"]
timeout = “1m”
data_format = “json”

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