You can install Telegraf on Ubuntu 20.04 either by downloading the DEB package file or directly from the InfluxData repos.
Install Telegraf using DEB Package File
To install Telegraf using the DEB binary, grab the binary installer from the InfluxDatadownloads page. You can simply obtain the link to binary installer and pull it with wget;
Once you have the binary downloaded, you can install it as follows
dpkg -i telegraf_1.14.3-1_amd64.deb
Install Telegraf from InfluxData Repos
If you want to install it from the InfluxData repos to ensure seamless updates whenever there are new releases, simply create the InfluxData repos as follows;
As of this writing, InfluxData repos for Ubuntu 20.04 do not provide InfluxDB package. However, InfluxDB package is available on the Focal Universe repos but it is not the latest version as of this writing. Hence, we prefer to install InfluxDB on Ubuntu 20.04 using the debian binary package as described above.
Start and enable InfluxDB to run on system boot;
systemctl enable --now influxdb
You can check the status by running the command below;
Same to Telegraf and InfluxDB, you can install Grafana on Ubuntu 20.04 using the debian package file or directly from Grafana repos.
Install Grafana using Debian Package File
To install Grafana using the debian package file, download the latest stable release version of Grafana from Grafana downloads page. The latest stable release version is usually selected by default;
Create InfluxDB database for storing the time series metrics to be collected by the Telegraf agent. Connect to InfluxDB using the influx client command.
influx
Connected to http://localhost:8086 version 1.8.0
InfluxDB shell version: 1.8.0
>
Next, create InfluxDB database. In this demo, we create a database called telegraf and a database user called telegraf.
create database telegraf
create user telegraf with password 'myP@SSword'
grant all on telegraf to telegraf
You can list the created databases;
show databases
name: databases
name
----
telegraf
_internal
To list users;
show users
user admin
---- -----
telegraf false
Exit InfluxDB and verify the connection to the database using the credentials created above;
is a plugin-driven server agent for collecting and sending metrics and events from databases, systems, and IoT sensors. All metrics are gathered from the declared inputs, and sent to the declared outputs. It is basically made up of four distinct plugin types:
Input Plugins collect metrics from the system, services
Output Plugins write metrics to various destinations such as InfluxDB for our case.
/etc/telegraf/telegraf.conf is the default Telegraf configuration file.
In this tutorial, we will configure TIG stack monitor system memory usage, system processes, disk usage, system load, system uptime and logged in users.
As such, we will generate our custom Telegraf configuration with the above specified metrics on the input filter. Custom Telegraf configuration file can be generated with telegraf command.
Create a backup of the original Telegraf configuration file.
mv /etc/telegraf/telegraf.conf{,.old}
Generate the Custom Telegraf for the specified metrics;
You can either create your own dashboards for Telegraf are find any that suit your needs from the already created Grafana community dashboards. In this tutorial, we are using the community Telegraf-system metrics dashboard created by user, jmutai.
To import the dashboard, click the + (plus) sign on the left panel of Grafana UI. You can either import using the dashboard ID or JSON file provided on specific Grafana dashboard page.
Click Load to load the dashboard.
Once the dashboard loads, select the InfluxDB data source and import the dashboard. You should now be able to see various dashboards detailing various system metrics;
We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!
gen_too
Co-founder of Kifarunix.com, Linux Tips and Tutorials.
Linux/Unix admin and author at Kifarunix.com.