Is it possible to use --pidfile option with telegraf running as a windows service?

Hi experts,
Is it possible to the use --pidfile startup option when telegraf is running as a windows service?

i tried adding this to “Start Parameters” field from Services > “Telegraf Data Collector Service” > Properties panel. But when i click OK or Apply, the parameters i specified get cleared out. Looks like the start parameters is not taking effect for the telegraf service.

Thanks for your help!


You can create the service manually to add the extra argument. It is possible to do this with the sc.exe command packaged with Windows but I recommend using NSSM instead.

Thanks Daniel. May i trouble you further to share either the sc.exe or NSSM arguments to create the service so i can create it just like “telegraf.exe --service install”? I’ll add pidfile argument to it. i’m worried that the service i install manually may differ from the one installed by telegraf.exe in some other ways that i don’t want…which is why i’m requesting for this info.
Thanks again!

I’m not in front of a Windows computer, so just a warning this is from memory:

With sc.exe, I’m actually not sure how to quote the command line, but it is similar to:

sc.exe create "Telegraf Data Collector Service" binPath= "C:\Program Files\Telegraf\telegraf.exe --config C:\Program Files\Telegraf\telegraf.conf"

With NSSM I have always opened the GUI with:

nssm install "Telegraf Data Collector Service"

Then just add the arguments, --config "C:\Program Files\Telegraf\telegraf.conf", with the correct path to the config file and then you will just need to add the --pidfile argument.

Thanks Daniel. Tied a few options but the service did not start or started without creating the pidfile.
For eg.,
sc.exe create telegraf binPath= “C:\Program Files\Telegraf\telegraf.exe --config C:\Program Files\Telegraf\telegraf.conf --pidfile C:\Program Files\Telegraf\” DisplayName= “Telegraf Data Collector Service”
created a service but on starting resulted in an error

No sweat. This is not urgent for me. i’m not blocked on this one currently. Thanks for your help.