Install Telegraf
This topic has instructions for installing Telegraf to work with Sumo Logic. We provide two sets of instructions:
- Install Telegraf in a non-Kubernetes environment
- Install Telegraf in a Kubenetes environment
Install Telegraf in a non-Kubernetes environment
This section has instructions for running Telegraf in a non-Kubernetes environment.
Prerequisites
This section describes prerequisites for installing Telgraf.
Privileges
Installing Telegraf typically requires root or administrator privileges. However, if you are using a pre-built binary, this is not the case.
Networking
Telegraf input plugins may require custom ports. You configure port mappings in telegraf.conf
, which, in default Linux installations, is located in /etc/telegraf
. In a Windows installation, the configuration file is in the directory where you unzipped the Telegraf archive, C:\InfluxData\telegraf
by default.
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 can be inaccurate.
Get Telegraf
Download the 1.16 release of Telegraf.
Install Telegraf on Ubuntu or Debian with apt-get
This section has instructions for installing the latest stable version of Telegraf on Ubuntu or Debian using the apt-get package manager.
- Add the InfluxData repository.
- To add the repository on Ubuntu, run the following command in a terminal window.
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
source /etc/lsb-release
echo "deb https://repos.influxdata.com/${DISTRIB_ID,,} ${DISTRIB_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
- To add the repository on Debian, run the following commands in a terminal window, skipping the comment lines, which begin with #.
# Before adding Influx repository, run this so that apt will be able to read the repository.
sudo apt-get update && sudo apt-get install apt-transport-https
# Add the InfluxData key
wget -qO-
https://repos.influxdata.co
m/influxdb.key | sudo apt-key add -
source /etc/os-release
test $VERSION_ID = "7" && echo "deb https://repos.influxdata.com/debian wheezy stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian stretch stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "10" && echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
- To add the repository on Ubuntu, run the following command in a terminal window.
- To install and start the Telegraf service, run the following commands in a terminal window:
sudo apt-get update && sudo apt-get install telegraf
sudo service telegraf start
Or, if your operating system uses systemd (Ubuntu 15.04+, Debian 8+):
sudo apt-get update && sudo apt-get install telegraf
sudo systemctl start telegraf
Manually install Telegraf on Debian from a .deb file
To manually install the Debian package from a .deb file:
- Download the latest Telegraf .deb release from the Telegraf section of the downloads page.
- Run the following command (making sure to supply the correct version number for the downloaded file):
sudo sudo dpkg -i telegraf_1.<version>_amd64.deb
Install Telegraf on Windows
Telegraf has native support for running as a Windows service.
- Download the Telegraf binary and unzip its contents to
C:\Program Files\InfluxData\Telegraf.
- Launch PowerShell as an administrator.
- In PowerShell, run these commands:
> cd "C:\Program Files\InfluxData\Telegraf"
> .\telegraf.exe --service install --config "C:\Program Files\InfluxData\Telegraf\telegraf.conf" - 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
Windows service 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
Command | Description |
---|---|
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 |
Install Telegraf in a Kubernetes environment
This section documents the steps for setting up Telegraf in a Kubernetes environment. Due to the dynamic nature of Kubernetes, we use the Telegraf Operator.
- First you need to set up Sumo Logic’s Kubernetes collection.
- If you have not set up Sumo Logic’s Kubernetes collection, perform these steps: follow these steps to set up Kubernetes collection.
- If you have already set up Kubernetes collection, you can upgrade to the latest version and enable the Telegraf Operator.
helm upgrade ... --set telegraf-operator.enabled=true ...
- After the Telegraf Operator pod is ready, add the following annotations to the pods from which you want to collect metrics.
telegraf.influxdata.com/inputs: |+
# Here goes telegraf configuration for scrapping metrics
(nginx example)
[[inputs.nginx]]
urls = ["http://localhost:8080/stub_status"]
telegraf.influxdata.com/class: sumologic-prometheus # points to predefined output configuration (exposing metrics to prometheus, so metadata enrichment can be performed)
prometheus.io/scrape: "true" # Enable scrapping metrics by prometheus
prometheus.io/port: "9273" # Defines from which port prometheus should scrape metrics
For more details and examples, see Configure Telegraf Input Plugins.
Configuring Telegraf
Telegraf supports a number of configuration options. Below is a summary of some of the most common ones. For the complete list, see Telegraf documentation.
Adjust the collection interval
You can adjust the collection and reporting intervals in the [agent]
block of your Telegraf configuration. The scraping interval is configured with the interval
property, and the flush_interval
property specifies the interval at which the data will be sent to configured outputs. Specify durations by combining an integer value and time unit as a string value. Valid time units are ns
, us
(or µs
), ms
, s
, m
, h
. The default is 10 seconds. The following example collects and send metrics to Sumo Logic every 30 seconds.
[agent]
interval = "30s"
flush_interval = "30s"
Add additional metadata
You may wish to add additional metadata to the metrics that Telegraf collects. You can do so with Global Tags. Global tags can be specified in the [global_tags]
table in key="value" format. All metrics that are collected will be tagged with the specified tags.
[global_tags]
dc = "us-east-1"