[inputs.exec] Error in plugin - every 2 hours

Hi

I have a Python script which pulls data from multiple sources and prints in InfluxDB line protocol. The script is invoked by exec input plugin in telegraf. It works great and data is written nicely to InfluxDB. But I have below errors on the screen.

2019-06-24T06:09:16Z E! [inputs.exec]: Error in plugin: exec: exit status 1 for command ‘python3 <file_name>.py’: Traceback (most recent call last):…
2019-06-24T08:10:16Z E! [inputs.exec]: Error in plugin: exec: exit status 1 for command ‘python3 <file_name>.py’: Traceback (most recent call last):…
2019-06-24T10:11:16Z E! [inputs.exec]: Error in plugin: exec: exit status 1 for command ‘python3 <file_name>.py’: Traceback (most recent call last):…

The errors are thrown consistently every 2 hours. The logging file of the python script does not show any error. All invocations are fully completed. I am looking for some guidance on how to troubleshoot it further?

It looks like your python script is exiting with an unhandled exception, printing out a traceback to stderr. I would just wrap the entire thing in a try/except statement and, since you are already logging, write the exception to the log with logging.exception().