How To Monitor NGINX using Telegraf and Graphite

How To Monitor NGINX using Telegraf and Graphite

Table of Contents


When enterprises run online services, web servers play an essential role. They allow the software to surface on the World Wide Web and make it accessible through web browsers for customers worldwide. When the performance of a web server gets degraded or, even worse, if a web server is entirely down, it impacts not only the business's bottom line but also the brand image for not providing reliable service to customers. Failure to manage web servers can also lead to security risks. Because of these serious consequences, companies heavily invest in monitoring their web servers.


Nginx is one of the most widely used software for web servers. In this article, we will learn the best way to monitor Nginx.


Before we start, check MetricFire. Metricfire provides comprehensive monitoring solutions with Hosted Graphite. You can set up various metrics to monitor Windows with minimal configuration. If you would like to learn more about it, please book a demo with us, or sign on for the free trial today. 


Key Takeaways

  1. Web servers are critical for online businesses, and their performance directly affects customer experience and brand image. Neglecting web server monitoring can lead to performance issues and security risks.
  2. Nginx is a versatile open-source software used for web servicing, reverse proxying, caching, load balancing, and more. It has evolved to handle diverse online activities effectively.
  3. Visualizing metrics data is crucial for understanding server performance. Grafana is a recommended open-source tool for creating customizable dashboards.
  4. Web server monitoring, especially with Nginx, is essential for maintaining optimal performance and ensuring a positive user experience.

What is Nginx?

Nginx is open-source software that enables running web services for online businesses. Its primary use case is web servicing, but it is designed to serve other purposes such as reverse proxying, caching, load balancing, media streaming, and more. Nginx can also work as a proxy server for IMAP, POP3, and SMTP. The initial version of the software supported simple HTML pages. However, as people use web services not only for web browsing but also for doing various activities such as watching, shopping, streaming, and more, Nginx has evolved to handle many different needs.


Key Nginx monitoring metrics

Nginx can power your online business to serve individual and enterprise customers. When there is a problem with the server software, the quality of your service gets degraded. This can lead to a negative ripple effect on your business. To prevent such an event, users will want to make sure that the software runs optimally using comprehensive monitoring metrics. In this section, let’s learn key Nginx monitoring metrics.


Requests per second

A web server needs to handle requests from users, but if your server receives a lot of requests in a short time, your server's performance can deteriorate. Requests per second, or RPS, is a measure that tracks the request count within one to five minutes typically. This measurement purely counts the requests without considering the size of each. By monitoring RPS, you can understand the optimal level of request count that a server can process.



When a server keeps getting stressed, it can eventually go down and cannot serve a single request. This is one of the most critical metrics since it can have a huge impact on serviceability. Uptime refers to how long a server is operating. 100% uptime is where people want to be. Cloud service providers aim at providing 99.9% or higher uptime. If the uptime number goes below 99.9%, you will want to check that server.


Error rates

An error rate is a result of a calculation that factors in the percentage of requests that fail. Occasionally you may see a 502 bad gateway nginx error for example. Nginx bad gateways are common website errors but you can monitor them by using MetricFire. Monitoring error rates can allow operation teams to efficiently evaluate the performance of each server and prioritize optimization. You can consider setting up an alert that is triggered when an error rate goes above a certain percentage.


Concurrent request count

A concurrent request count shows you how many requests are being handled at the same time at a particular time. These metrics also help people to understand the server load. Normally, when a server receives multiple requests at the same time, while some are being handled, the rest become on hold. This however can lead to a timeout for the waiting requests. When you have too many concurrent requests, it can cause broad failures.


Hardware resource metrics

In addition to the server metrics, you will need to monitor hardware resources such as memory usage, CPU capacity, storage space, and more. Server software runs on server hardware thus if the server suffers from a lack of memory space, for example, it cannot serve requests fast enough. To operate the server software, operation teams need to check if there is any spike in resource usage or any abnormal activities in this space.



How You Can Configure Nginx with Telegraf and Graphite

You can monitor these metrics using Telegraf and Graphite. To enable this feature, you first need to install Telegraf and send metrics data to Graphite. Let’s find out how we can install Telegraf.


Install Telegraf

If you use Windows, run the following commands in Powershell.

wget -UseBasicParsing -OutFile
Expand-Archive .\ -DestinationPath 'C:\Program Files\InfluxData\telegraf'


The download file above is the latest stable version as of November 2022. If you want to find the later version, check the Telegraf download page.


If you use macOS, you can run the command below.

brew update
brew install telegraf


On Linux, you can download it using the command.

tar xf telegraf-1.24.2_linux_amd64.tar.gz


After you install Telegraf, configure Telegraf to send syslog to Graphite.


Create a configuration file

Creating a configuration file differs depending on your operating system.

  • Windows: run ./telegraf.exe --output-filter graphite config > telegraf.conf 
  • MacOS: find the configuration file at /usr/local/etc/telegraf/telegraf.conf 
  • Linux: Find the configuration file at /etc/telegraf/telegraf.conf


Modify config to send metrics to hosted Graphite

The main mechanism for sending metrics to Graphite is via TCP protocol. To send metrics, you need to change config variables according to your settings within the configuration file you created or found. A sample configuration looks like below.

## This is the configuration for Graphite server to send metrics to
  ## TCP endpoint for your graphite instance.
  ## If multiple endpoints are configured, the output will be load balanced.
  ## Only one of the endpoints will be written to with each iteration.
  ## You can put your hosted graphite endpoint URL
  servers = [""]
  ## Metrics prefix name
  prefix = "YOUR_API_KEY.telegraf"
  ## Graphite output template
  template = "host.tags.measurement.field"

  ## Graphite templates patterns
  ## 1. Template for cpu
  ## 2. Template for disk*
  ## 3. Default template
  # templates = [
  #  "cpu",
  #  "disk* measurement.field",
  #  "host.measurement.tags.field"

  ## Enable Graphite tags support
  # graphite_tag_support = false

  ## Metric name and field separating character for Graphite tag
  # graphite_separator = "."

  ## timeout in seconds for the write connection to Graphite
  timeout = 2

  ## 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


Among the configuration above, you need to mainly check the three areas:


  • [[outputs.graphite]]
  • The server URL in the servers list field:
  • Put your prefix following the pattern of "YOUR_API_KEY.telegraf".


Save the configuration file after changing the values. Next, you need to restart the Telegraf service to apply the changes. 


Launch Telegraf

Finally, you need to launch Telegraf to apply the changes. The starting command differs from the operating system.



./telegraf.exe -service install -config 'C:\Program Files\telegraf\telegraf.conf'
net start telegraf



brew services restart telegraf

brew services restart telegraf



sudo service telegraf start


sudo systemctl start telegraf


When Telegraf sends out data, it can decide the output data format following your configuration. 


Creating a dashboard to monitor NGINX metrics

After you set up Nginx and Graphite, the next important step is creating a dashboard to efficiently monitor the metrics data from the server software. When you interpret data, visualization is an essential component since we can comprehend pictures much faster. One of the best ways to visualize Graphite data is by utilizing Grafana. Grafana is an open-source monitoring tool that allows you to download data from different sources and visualize it on beautiful, customizable dashboards. After creating the Grafana dashboard, you need to add information panels to it. There are different types of panels in Grafana that you can use for different purposes.


Monitoring Nginx with MetricFire

MetricFire provides both Hosted Graphite and hosted dashboards as a single software product. It does all the necessary work to install, configure, and maintain these monitoring tools. With MetricFire you can have Hosted Graphite dashboards and many third-party service integrations all hosted within a web application saving you a lot of time and money. There is also an option to install other customized plugins. MetricFire works transparently and allows you to view its internal system metrics on an open public page. It gives you control over your data. You can access and export your data at any time. For more details check out our other tutorial here.



We learned the concept of Nginx and how to monitor Nginx using Telegraf and Graphite. Graphite is a great open-source tool, but using and maintaining open-source software can be a demanding task. MetricFire provides hosted Graphite for users so that people can focus on what matters most and delegate maintenance jobs.


Try MetricFire for free and enjoy all the benefits of using a hosted service for half the price of competitors! Book a demo with the MetricFire team and ask any questions about the operation of our system.

You might also like other posts...
metricfire Jan 24, 2024 · 6 min read

Monitor Heroku Add-Ons Using Hosted Graphite

Monitoring your Heroku stack helps you understand the performance of your application and infrastructure.... Continue Reading

metricfire Jan 23, 2024 · 8 min read

Monitor Redis Using Telegraf and MetricFire

Monitoring Redis instances is essential for maintaining performance, reliability, and security. It allows you... Continue Reading

metricfire Jan 19, 2024 · 8 min read

Monitor Your Mailchimp Campaigns Using Telegraf

Monitoring your email campaigns helps you track key performance indicators (KPIs) such as open... Continue Reading

header image

We strive for
99.999% uptime

Because our system is your system.

14-day trial 14-day trial
No Credit Card Required No Credit Card Required