How to Install Telegraf on Ubuntu 18.04 LTS - TechBeginner

Welcome to TechBeginner.in, Tech Beginner provides technical blog for Online Linux Tutorials, Ubuntu Tutorials, Redhat Tutorials and CentOS 7, Configuration of server like Web Server, Application server, Database server, Window server, networking, html, css, java script, php, wordpress, opencart, magento, joomla and etc.

How to Install Telegraf on Ubuntu 18.04 LTS

Share This


 

Introduction

 

Telegraf is a specialist written in Go for gathering execution measurements from the framework it's running on and the administrations running on that framework. The gathered measurements are yield to InfluxDB or other upheld information stores. From InfluxDB, you ought to have the option to envision patterns and frameworks execution utilizing apparatuses like Grafana.

 

In this post, We will install and configure Telegraf on ubuntu 18.04 LTS.

 

Step 1: Adding Repository

You need to add 1st Influxdata repository, Once the repo is added, the bundle would then be able to be introduced utilizing an able bundle chief. Add the InfluxData repo in the path /etc/apt/sources.list.d/influxdata.list

 

sudo echo deb https://repos.influxdata.com/ubuntu bionic stable > sudo tree /etc/apt/sources.list.d/influxdata.list 


Step 2: Adding Key 

 

Now Import apt key by using the following command.

 

sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
 


Step 3: Updating Repository

 

Its time to update the ubuntu current repository to get telegraf repo to install using apt, Use the following command. 


sudo apt-get update

 

Step 4: Installing Telegraf

 

Use the following command to install telegraf package on ubuntu 18.04 LTS.


sudo apt-get install telegraf -y
 

 

Step 5: Getting Telegraf Status

 

After installation the telegraf package you need to verify the telegraf service is runing state or not, Use the following command for the same.


sudo systemctl status telegraf

 

You should get the output like this :-


Step 6: Telegraf configuration with Prometheus

You need to open the telegraf config file using vim text editor and goto line number 105 and comment it this line disable the influxdb like this.

 


after this you need to add the promethe configuration with port number 9125 like this.

sudo vim /etc/telegraf/telegraf.conf

add the following config in telegraf config file. 

[[outputs.prometheus_client]]
    listen = "0.0.0.0:9125"


Save and exit from the vim text editor and restrat the telegraf service bu using the following command.

sudo systemctl restart telegraf

Now you need to verify the telegraf service with logs, Use the following command.

sudo systemctl status telegraf

You should get output like this.


Step 7: Adding telegraf in prometheus


To configure telegraf in prometheus, You need to add the following config in prometheus config file /etc/prometheus/prometheus.yml and restart the prometheus service.

sudo vim /etc/prometheus/prometheus.yml

 

and add the telegraf config like this.

  - job_name: Telegraf
    # If telegraf is installed, grab stats about the local
    # machine by default.
    static_configs:
      - targets: ['localhost:9125']

 

 

Save and exit from prometheus main configuration file and restart the prometheus service to get new changes.

sudo systemctl restart prometheus

To verify the prometheus service, Use the following command.


sudo systemctl status prometheus


You should get output like this.

Step 8: Testing Telegraf in Prometheus


Here you need to open the prometheus in GUI using http://localhost:9090 or http://IP_Addeess:9090 and execute the up query to get system metric like this.

If you are able to see the telegraf tag in prometheus query result, So that's mean, You have successfully installed and configure telegraf with prometheus.

Conclusion

Since you have Telegraf running, you can experience our guide on the most proficient method to Monitor Linux System with Grafana and Telegraf to figure out how to design Telegraf and use it with Grafana.


No comments:

Post a Comment