4.2 KiB
title | description | menu | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Run Telegraf as a Windows service | How to configure Telegraf as a Windows service using PowerShell. |
|
Telegraf natively supports running as a Windows service.
Download and run Telegraf as a Windows service
{{% note %}} Installing a Windows service requires administrative permissions. To run PowerShell as an administrator, see "Launch PowerShell as administrator". {{% /note %}}
In PowerShell as an administrator, do the following:
-
Use the following commands to download the Telegraf Windows binary and extract its contents to
C:\Program Files\InfluxData\telegraf\
:> wget https://dl.influxdata.com/telegraf/releases/telegraf-{{% latest-patch %}}_windows_amd64.zip -UseBasicParsing -OutFile telegraf-{{< latest-patch >}}_windows_amd64.zip > Expand-Archive .\telegraf-{{% latest-patch %}}_windows_amd64.zip -DestinationPath 'C:\Program Files\InfluxData\telegraf\'
-
Move the
telegraf.exe
andtelegraf.conf
files fromC:\Program Files\InfluxData\telegraf\telegraf-{{% latest-patch %}}
up a level toC:\Program Files\InfluxData\telegraf
:> cd "C:\Program Files\InfluxData\telegraf" > mv .\telegraf-{{% latest-patch %}}\telegraf.* .
Or create a Windows symbolic link (Symlink) to point to this directory.
{{% note %}} The instructions below assume that either the
telegraf.exe
andtelegraf.conf
files are stored inC:\Program Files\InfluxData\telegraf
, or you've created a Symlink to point to this directory. {{% /note %}} -
Install Telegraf as a service:
> .\telegraf.exe --service install --config "C:\Program Files\InfluxData\telegraf\telegraf.conf"
Make sure to provide the absolute path of the
telegraf.conf
configuration file, otherwise the Windows service may fail to start. -
To test that the installation works, run:
> C:\"Program Files"\InfluxData\telegraf\telegraf.exe --config C:\"Program Files"\InfluxData\telegraf\telegraf.conf --test
-
To start collecting data, run:
telegraf.exe --service start
Logging and troubleshooting
When Telegraf runs as a Windows service, Telegraf logs messages to Windows event logs. If the Telegraf service fails to start, view error logs by selecting Event Viewer→Windows Logs→Application.
Windows service commands
The following commands are available:
Command | Effect |
---|---|
telegraf.exe --service install |
Install telegraf as a service |
telegraf.exe --service uninstall |
Remove the telegraf service |
telegraf.exe --service start |
Start the telegraf service |
telegraf.exe --service stop |
Stop the telegraf service |