Telefraf plugin input.exe don't execute python script when telegraf is executed as service while works ok in test mode


I want to excute a python script with the inputs.exec plugin , the configuration is:


Commands array

commands = [“pythionE:/sw/telegraf_2/” ]
name_suffix = “_mycollector”
data_format = “influx”

This is the script, it does nothing interesting, but it is usefull for doing some tests:
import time
linea=‘example,tag1=a,tag2=b i=42i,j=43i,k=%ii’%int(time.time())

The script writes in the stdout a valid line for influxdb, also it writes to a file to check if it is executed. The line contains a timestamp for trace the test.log file.

If I run telegraf in test mode, it shows the output and test.log file is updated.

telegraf.exe --config telegraf.conf --debug --test

example_mycollector,host=vm-bar-gen-win1,tag1=a,tag2=b i=42i,j=43i,k=1663086182i 1663086182000000000

I created a telegraf service
telegraf.exe --service install --service-name telegraf_1 --service-display-name “telegraf_1” --config “E:\sw\telegraf\telegraf.conf”

The service is started OK but the test.log file is not writen nor the output file of outputs.file plugin. Configuring other input plugins as inputs.cpu or inputs.mem, they work ok, the only that is not executed is inputs.exec


Having exec work manually, but not as a service, usually indicates that the service itself does not have permissions to the binary or script you are trying to execute. What do the Telegraf log show? They would confirm this.


There isn’t anything in the log of telegraf when I run it as a service. When I run it in test mode:
telegraf.exe --config telegraf.conf --debug --test
or in console:
telegraf.exe --config telegraf.conf --debug

the log is written (nothing from inputs.exec and neither other plugin)
The binary script is python.exe, so , how do I give the service the permissions to python.exe?