Error handling in Exec plugin


#1

I am executing a script using [[input.exec]] and want to handle error in the script in graceful way. As the exec plugin can parse the output of the script either in “influx” or “json” wondering if there is any better way to inform telegraf that script failed because of some reason.
Example use case : I have a multiple scripts that connect to different services using credentials and those scripts process response and converts it into json/influx format and emits to exec plugin. Is there a way if script can send error message to exec plugin so that it gives proper error message instead of parsing error?


#2

If you write an error message to stderr and exit with a non-zero status code Telegraf will include the message in its logging output.


#3

Thanks Daniel, it worked.