diff --git a/cmd/telegraf/telegraf.go b/cmd/telegraf/telegraf.go index 5b7295d6d..93336ffb4 100644 --- a/cmd/telegraf/telegraf.go +++ b/cmd/telegraf/telegraf.go @@ -55,6 +55,7 @@ var fUsage = flag.String("usage", "", "print usage for a plugin, ie, 'telegraf --usage mysql'") var fService = flag.String("service", "", "operate on the service (windows only)") +var fServiceName = flag.String("service-name", "telegraf", "service name (windows only)") var fRunAsConsole = flag.Bool("console", false, "run as console application (windows only)") var ( @@ -327,7 +328,7 @@ func main() { if runtime.GOOS == "windows" && !(*fRunAsConsole) { svcConfig := &service.Config{ - Name: "telegraf", + Name: *fServiceName, DisplayName: "Telegraf Data Collector Service", Description: "Collects data using a series of plugins and publishes it to" + "another series of plugins.", diff --git a/docs/WINDOWS_SERVICE.md b/docs/WINDOWS_SERVICE.md index 886887d52..51ce6a7a6 100644 --- a/docs/WINDOWS_SERVICE.md +++ b/docs/WINDOWS_SERVICE.md @@ -46,6 +46,16 @@ Telegraf can manage its own service through the --service flag: | `telegraf.exe --service start` | Start the telegraf service | | `telegraf.exe --service stop` | Stop the telegraf service | +## Install multiple services + +You can install multiple telegraf instances with --service-name flag: + +``` + > C:\"Program Files"\Telegraf\telegraf.exe --service install --service-name telegraf-1 + > C:\"Program Files"\Telegraf\telegraf.exe --service install --service-name telegraf-2 + > C:\"Program Files"\Telegraf\telegraf.exe --service uninstall --service-name telegraf-1 +``` + Troubleshooting common error #1067 When installing as service in Windows, always double check to specify full path of the config file, otherwise windows service will fail to start diff --git a/internal/usage_windows.go b/internal/usage_windows.go index db5e492a9..0bdd73026 100644 --- a/internal/usage_windows.go +++ b/internal/usage_windows.go @@ -33,6 +33,7 @@ The commands & flags are: --console run as console application (windows only) --service operate on the service (windows only) + --service-name service name (windows only) Examples: @@ -59,4 +60,7 @@ Examples: # install telegraf service telegraf --service install --config "C:\Program Files\Telegraf\telegraf.conf" + + # install telegraf service with custom name + telegraf --service install --service-name=my-telegraf `