Operations 5 min read

Monitoring Nginx with Telegraf, InfluxDB, and Grafana

After setting up an Nginx cluster, this guide explains how to enable the nginx-status module, collect metrics with Telegraf, store them in InfluxDB, and visualize the data using Grafana, providing a complete solution for real-time Nginx monitoring.

Selected Java Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Monitoring Nginx with Telegraf, InfluxDB, and Grafana

After building an Nginx cluster, the next step is to study daily Nginx monitoring.

How to monitor Nginx? You can find it on Baidu: nginx-status .

Nginx+Telegraf+Influxdb+Grafana

By using the Telegraf monitoring plugin to periodically collect Nginx status, store it in the time‑series database InfluxDB, and display it with Grafana, you obtain a complete monitoring solution.

1. Enable nginx-status in Nginx

If you compile Nginx from source, add the stub status module during configuration:

./configure --with-http_stub_status_module

You can see more module options with ./configure --help , then compile and install.

If you install Nginx via apt-get install , check whether the stub_status module is supported:

Run nginx -V and look for --with-http_stub_status_module in the output.

Modify the Nginx configuration file and add the following location block in the server section:

location /nginx-status {
    allow 127.0.0.1; // allowed IP
    deny all;
    stub_status on;
    access_log off;
}

Reload Nginx and access nginx-status to view the metrics.

Explanation of the output:

active connections – number of active connections

server accepts handled requests – total connections accepted, handshakes created, and requests processed

reading – connections where Nginx is reading the request header

writing – connections where Nginx is writing the response back to the client

waiting – idle keep‑alive connections (active – (reading + writing))

2. Install and configure Telegraf for Nginx monitoring

Refer to the official Telegraf documentation for installation.

https://www.influxdata.com/time-series-platform/telegraf/
wget https://dl.influxdata.com/telegraf/releases/telegraf-1.4.3-1.x86_64.rpm
sudo yum localinstall telegraf-1.4.3-1.x86_64.rpm

Then edit telegraf.conf to configure the InfluxDB connection.

Add the Nginx input plugin configuration (see the screenshot).

After saving the configuration, restart the Telegraf service.

3. Integrate Nginx monitoring into Grafana

Grafana supports InfluxDB as a data source. After adding the InfluxDB datasource configured in the previous step, create a custom Nginx monitoring dashboard:

Data source: InfluxDB

FROM: nginx

SELECT: field(accepts)

Resulting visualization:

By combining Nginx, Telegraf, InfluxDB, and Grafana, you achieve a convenient and powerful Nginx monitoring solution.

Source: cnblogs.com/tianqing/p/7745436.html

monitoringoperationsNginxInfluxDBGrafanaTelegraf
Selected Java Interview Questions
Written by

Selected Java Interview Questions

A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.