Documentation

Install Telegraf

This page provides directions for installing, starting, and configuring Telegraf. To install Telegraf, do the following:

Download

Download the latest Telegraf release at the InfluxData download page.

Verify Linux releases using GPG

InfluxData uses GPG (GnuPG) to sign released software and provides public key and encrypted private key (.key file) pairs that you can use to verify the integrity of downloads from the InfluxData repository.

Before running the install sample code, substitute the key-pair compatible with your OS version:

For newer OS releases (for example, Ubuntu 20.04 LTS and newer) that support subkey verification:

  • Private key file: influxdata-archive.key
  • Public key: 943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515

For all Ubuntu and Debian versions, including older versions (for example, CentOS/RHEL 7, Ubuntu 18.04 LTS, or Debian Buster) that don’t support subkeys for verification:

  • Private key file: influxdata-archive_compat.key
  • Public key: 393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c

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.

Install

Debian and Ubuntu users can install the latest stable version of Telegraf using the apt-get package manager.

Install from the InfluxData repository

Run the following commands using apt-get to install Telegraf from the InfluxData repository:

# influxdata-archive_compat.key GPG Fingerprint: 9D539D90D3328DC7D6C8D3B9D8FF8E1F7DF8B07E
curl -s https://repos.influxdata.com/influxdata-archive_compat.key > influxdata-archive_compat.key
echo '393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key' | sha256sum -c && cat influxdata-archive_compat.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install telegraf
curl -s https://repos.influxdata.com/influxdata-archive.key > influxdata-archive.key
echo '943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515 influxdata-archive.key' | sha256sum -c && cat influxdata-archive.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg > /dev/null
echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update && sudo apt-get install telegraf

Install from a .deb file

To manually install the Debian package from a .deb file:

  1. Download the latest Telegraf .deb release from the Telegraf section of the downloads page.

  2. Run the following command (making sure to supply the correct version number for the downloaded file):

    sudo dpkg -i telegraf_1.29.0-1_amd64.deb
    

To learn how to manually install the RPM package from a file, see the downloads page.

To use the yum package manager to install the latest stable version of Telegraf, follow these steps:

  1. In your terminal, enter the following command to add the InfluxData repository to the yum configuration:

    cat <<EOF | sudo tee /etc/yum.repos.d/influxdb.repo
    [influxdb]
    name = InfluxData Repository - Stable
    baseurl = https://repos.influxdata.com/stable/\$basearch/main
    enabled = 1
    gpgcheck = 1
    gpgkey = https://repos.influxdata.com/influxdata-archive_compat.key
    EOF
    
  2. Enter the following command to install telegraf from the repository.

    sudo yum install telegraf
    

The telegraf configuration file is installed at /etc/telegraf/telegraf.conf.

The openSUSE Build Service provides RPM packages for SUSE Linux.

To use the zypper package manager to install the latest stable version of Telegraf, follow these steps:

  1. In your terminal, enter the following command to add the Go repository to the zypper configuration:

    # add go repository
    zypper ar -f obs://devel:languages:go/ go
    
  2. Enter the following command to install telegraf.

    # install latest telegraf
    zypper in telegraf
    

Telegraf is part of the FreeBSD package system.

To use the pkg package manager to install the latest stable version of Telegraf, enter the following command:

sudo pkg install telegraf

The telegraf configuration file is installed at /usr/local/etc/telegraf.conf. Examples are installed at /usr/local/etc/telegraf.conf.sample.

Choose from the following options to install Telegraf for macOS:

Install using Homebrew

Users of macOS 10.8 and higher can install Telegraf using the Homebrew package manager.

The telegraf binary installed by Homebrew differs from the macOS .dmg builds available from the downloads page.

  • telegraf (Homebrew) isn’t a static binary.
  • telegraf (Homebrew) works with the Telegraf CPU plugin (due to Homebrew support for Cgo). The .dmg builds available on downloads don’t support the CPU plugin.

To install using Homebrew, do the following:

  1. If you haven’t already, follow the instructions to install the Homebrew package manager.

  2. Enter the following commands to update brew and install Telegraf:

    brew update && brew install telegraf
    

    The path where brew installs the telegraf.conf configuration file depends on your system architecture:

    • ARM-based (Apple Silicon) systems: /opt/homebrew/etc/telegraf.conf
    • Intel-based (x86_64) systems: /usr/local/etc/telegraf.conf
  3. Choose one of the following methods to start Telegraf and begin collecting and processing metrics:

Run Telegraf in your terminal

To run telegraf in your terminal (in the foreground and not as a service), enter the following command:

telegraf -config /opt/homebrew/etc/telegraf.conf
telegraf -config /usr/local/etc/telegraf.conf

Run Telegraf as a background service

In your terminal, enter the following command to add telegraf to your system’s LaunchAgents:

ln -sfv /opt/homebrew/opt/telegraf/*.plist ~/Library/LaunchAgents
ln -sfv /usr/local/opt/telegraf/*.plist ~/Library/LaunchAgents

The next time you login, launchd starts the telegraf service.

To immediately start the telegraf service, enter the following command:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.telegraf.plist

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:

  1. 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.29.0_windows_amd64.zip `
    -UseBasicParsing `
    -OutFile telegraf-1.29.0_windows_amd64.zip `
    Expand-Archive .\telegraf-1.29.0_windows_amd64.zip `
    -DestinationPath 'C:\Program Files\InfluxData\telegraf\'
    
  2. Choose one of the following steps to place your telegraf.exe and telegraf.conf files in C:\Program Files\InfluxData\telegraf:

    • Move the telegraf.exe and telegraf.conf files from C:\Program Files\InfluxData\telegraf\telegraf-1.29.0 to the parent directory C:\Program Files\InfluxData\telegraf–for example:

      cd "C:\Program Files\InfluxData\telegraf";
      mv .\telegraf-1.29.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.

  1. 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]]
    ...
    
  2. Run the following command to install Telegraf and the configuration as a Windows service. For the --config option, pass the absolute path of the telegraf.conf configuration file.

    .\telegraf.exe --service install `
    --config "C:\Program Files\InfluxData\telegraf\telegraf.conf"
    
  3. 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.

  4. 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 ViewerWindows LogsApplication.

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 custom configuration file

The telegraf config command lets you generate a configuration file using Telegraf’s list of 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 config > telegraf.conf
.\telegraf.exe config > telegraf.conf

The generated file contains settings for all available plugins–some are enabled and the rest are commented out.

Create a configuration file with specific input and output plugins

To generate a configuration file that contains settings for only specific input and output plugins, specify telegraf plugin filters–for example:

telegraf \
--input-filter <pluginname>[:<pluginname>] \
--output-filter <outputname>[:<outputname>] \
config > telegraf.conf
.\telegraf.exe `
--input-filter <pluginname>[:<pluginname>] `
--output-filter <outputname>[:<outputname>] `
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.

  1. Prerequisites
  2. Build the custom builder tool
  3. Run the custom builder to create a telegraf binary

Prerequisites

Build the custom builder tool

  1. Clone the Telegraf repository:

    git clone https://github.com/influxdata/telegraf.git
    
  2. Change directories into the top-level of the Telegraf repository:

    cd telegraf
    
  3. Build the Telegraf custom builder tool by entering 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!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: