How to configure and integrate Nginx with 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 configure and integrate Nginx with Telegraf on ubuntu 18.04 LTS

Share This

 

In this post, We will configure and integrate Nginx monitoring metrics with Telegraf on ubuntu 18.04 LTS


I believe you have already installed and configure prometheus ,Telegraf and MongoDB on your machine if not so then go through the given url to setup prometheus with telegraf on your machine.

 
https://www.techbeginner.in/2020/12/how-to-install-prometheus-on-ubuntu.html
https://www.techbeginner.in/2021/01/how-to-install-telegraf-on-ubuntu-1804.html
https://www.techbeginner.in/2019/12/how-to-install-nginx-using-ubuntu-1604.html

 

nginx [engine x] is a HTTP and converse intermediary worker, a mail intermediary worker, and a nonexclusive TCP/UDP intermediary worker, initially composed by Igor Sysoev. For quite a while, it has been running on numerous intensely stacked Russian destinations including Yandex, Mail.Ru, VK, and Rambler. As per Netcraft, nginx served or proxied 23.21% busiest destinations in December 2020. Here are a portion of the examples of overcoming adversity: Dropbox, Netflix, Wordpress.com, FastMail.FM. 



Step 1: Enable Nginx Plugin in Telegraf


By default telegraf we have got the telegraf.d directory on /etc/telegraf/telegraf.d in this path, You need to create a nginx.conf configuration file and add the following nginx plugin syntax by following the given command.

 

sudo vim /etc/telegraf/telegraf.d/nginx.conf

Paste the given code to enable the Nginx plugin in telegraf.

 

# Read Nginx's basic status information (ngx_http_stub_status_module)
[[inputs.nginx]]
  ## An array of Nginx stub_status URI to gather stats.
  urls = ["http://localhost/server_status"]

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

  ## HTTP response timeout (default: 5s)
  response_timeout = "5s" 



Here you can uncomments the other parameter to use the username and password for Nginx monitoring user as per your requirement, Save and exit from the vim text editor.


Step 2: Restart the Telegraf


You need to restart the Telegraf service to get new changes for Nginx metric in prometheus, Use the following command for the same.

©©sudo systemctl restart telegraf


Conclusion

We have successfully integrate nginx with Telegraf in our Ubuntu 18.04 server.

No comments:

Post a Comment