Install Telegraf
This page provides directions for installing, starting, and configuring Telegraf. To install Telegraf, do the following:
Requirements
Installation of the Telegraf package may require root
or administrator privileges to complete successfully.
Networking
Telegraf offers multiple service input plugins that may
require custom ports.
Modify port mappings through the configuration file (telegraf.conf
).
For Linux distributions, this file is located at /etc/telegraf
for default installations.
For Windows distributions, the configuration file is located in the directory where you unzipped the Telegraf ZIP archive.
The default location is C:\InfluxData\telegraf
.
NTP
Telegraf uses a host’s local time in UTC to assign timestamps to data. Use the Network Time Protocol (NTP) to synchronize time between hosts. If hosts’ clocks aren’t synchronized with NTP, the timestamps on the data might be inaccurate.
Download and install Telegraf
Recommended:: Before you open and install packages and downloaded files, use SHA checksum verification and GPG signature verification to ensure the files are intact and authentic.
SHA checksum and GPG signature verification are complementary checks.
For some Linux platforms, the installation instructions include steps to verify downloaded packages and binaries.
For more information, see the following:
Ubuntu & Debian RedHat & CentOS SLES & openSUSE FreeBSD/PC-BSD Linux binaries (AMD) Linux binaries (ARM) macOS Windows
Download and run Telegraf as a Windows service
Installing a Windows service requires administrative permissions. To run PowerShell as an administrator, see Launch PowerShell as administrator.
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-1.33.0_windows_amd64.zip ` -UseBasicParsing ` -OutFile telegraf-1.33.0_windows_amd64.zip Expand-Archive .\telegraf-1.33.0_windows_amd64.zip ` -DestinationPath 'C:\Program Files\InfluxData\telegraf\'
Choose one of the following steps to place your
telegraf.exe
andtelegraf.conf
files inC:\Program Files\InfluxData\telegraf
:Move the
telegraf.exe
andtelegraf.conf
files fromC:\Program Files\InfluxData\telegraf\telegraf-1.33.0
to the parent directoryC:\Program Files\InfluxData\telegraf
–for example:cd "C:\Program Files\InfluxData\telegraf"; mv .\telegraf-1.33.0\telegraf.* .
Or, create a Windows symbolic link (Symlink) for
C:\Program Files\InfluxData\telegraf
that points to the extracted directory.
The remaining instructions assume that telegraf.exe
and telegraf.conf
files are stored in
C:\Program Files\InfluxData\telegraf
or that you created a Symlink to point to this directory.
Optional: Enable a plugin to collect Windows-specific metrics–for example, uncomment the
inputs.win_services
plugin configuration line:... # # Input plugin to report Windows services info. # # This plugin ONLY supports Windows [[inputs.win_services]] ...
Run the following command to install Telegraf and the configuration as a Windows service. For the
--config
option, pass the absolute path of thetelegraf.conf
configuration file..\telegraf.exe --service install ` --config "C:\Program Files\InfluxData\telegraf\telegraf.conf"
To test that the installation works, enter the following command:
.\telegraf.exe ` --config C:\"Program Files"\InfluxData\telegraf\telegraf.conf --test
When run in test mode (using the
--test
flag), Telegraf runs once, collects metrics, outputs them to the console, and then exits. It doesn’t run processors, aggregators, or output plugins.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 |
Generate a configuration file
The telegraf config
command lets you generate a configuration file from
Telegraf’s plugin list.
- Create a configuration file with default input and output plugins
- Create a configuration with specific input and output plugins
Create a configuration file with default input and output plugins
To generate a configuration file with default input and output plugins enabled, enter the following command in your terminal:
.\telegraf.exe config > telegraf.conf
Create a configuration file with specific input and output plugins
To generate a configuration file that contains settings for only specific plugins,
use the --input-filter
and --output-filter
options to
specify input plugins
and output plugins–for example:
.\telegraf.exe `
--input-filter cpu:http `
--output-filter influxdb_v2:file `
config > telegraf.conf
For more advanced configuration details, see the configuration documentation.
Custom-compile Telegraf
Use the Telegraf custom builder tool to compile Telegraf with only the plugins you need and reduce the Telegraf binary size.
Prerequisites
- Follow the instructions to install Go for your system.
- Create your Telegraf configuration file with the plugins you want to use.
Build the custom builder tool
Clone the Telegraf repository and then change into the repository directory–for example, enter the following command in your terminal:
git clone https://github.com/influxdata/telegraf.git && cd ./telegraf
To build the Telegraf custom builder tool, enter the following command:
make build_tools
Run the custom builder to create a telegraf
binary
The custom builder builds a telegraf
binary with only the plugins included in
the specified configuration files or directories.
Run the custom_builder
tool with at least one --config
or --config-directory
flag to specify Telegraf configuration files to build from.
--config
: accepts local file paths and URLs.--config-dir
: accepts local directory paths.
You can include multiple --config
and --config-dir
flags.
Examples
Single Telegraf configuration
./tools/custom_builder/custom_builder --config /etc/telegraf.conf
Single Telegraf configuration and Telegraf configuration directory
./tools/custom_builder/custom_builder \
--config /etc/telegraf.conf \
--config-dir /etc/telegraf/telegraf.d
Remote Telegraf configuration
./tools/custom_builder/custom_builder \
--config http://url-to-remote-telegraf/telegraf.conf
After a successful build, you can view your customized telegraf
binary within the top level of your Telegraf repository.
Update your custom binary
To add or remove plugins from your customized Telegraf build, edit your configuration file, and then run the custom builder to regenerate the Telegraf binary.
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Telegraf and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.