Quickly Deploy Prometheus Nginx Log Exporter for Deep Nginx Monitoring
This guide explains how to install and configure the prometheus-nginxlog-exporter in the Yunzhou Observability platform, covering its core features, metric types, one‑click deployment steps, chart visualization, alert rule setup, and common troubleshooting tips for comprehensive Nginx monitoring.
Monitoring Background
In modern web application architectures, Nginx is widely used as a high‑performance web server and reverse proxy. Monitoring Nginx runtime status and access logs is essential for service stability and user experience. The prometheus-nginxlog-exporter converts Nginx access logs into Prometheus metrics, helping operators and developers obtain key information quickly. Yunzhou Observability integrates and extends this exporter to reduce storage redundancy, improve collection and query performance, and support visualization and alerting.
Tool Basic Information
The prometheus-nginxlog-exporter, developed by Martin Helmich, continuously reads Nginx log files (or similar formats) and exports extracted metrics to Prometheus for monitoring and analysis. The project is open‑source on GitHub, with Docker images available on quay.io and pkg.github.com, and is licensed under MIT.
Exporter Feature Overview
(1) Core Functions
Supports reading Nginx logs from local files or Syslog, compatible with multiple log formats.
Transforms key log data (request count, response size, response time, etc.) into Prometheus‑compatible metrics.
Allows multi‑namespace configuration to monitor several log sources simultaneously, using labels to differentiate metrics.
Provides flexible configuration via command‑line arguments or configuration files.
(2) Types of Monitoring Data
Request count statistics by HTTP status code and method.
Request latency analysis, including average and maximum response times.
Client IP statistics for source analysis and attack mitigation.
URI access frequency to identify hot and cold pages.
The exporter also supports custom log format parsing rules to adapt to different Nginx log structures.
One‑Click Installation in Yunzhou Observability
Yunzhou Observability provides a one‑click deployment of the exporter, with source code enhancements that pre‑filter request URLs and retain only the P99 latency metric, reducing data volume.
(1) Deploy the "Nginx Metrics (log parsing)" Application
In the platform’s "Integrated Installation – Application Marketplace", locate the "Nginx Metrics (log parsing)" app, select the Nginx host, set collection interval and timeout, and provide the log path and format. After configuration, install the app.
To verify the Nginx log format configuration file path:
Run nginx -t to display the main configuration file (e.g., /etc/nginx/nginx.conf).
Open /etc/nginx/nginx.conf and locate the include directive.
If it contains include /etc/nginx/conf.d/*.conf;, check all .conf files in that directory.
In one of the /etc/nginx/conf.d/*.conf files you will find lines such as:
log_format custom '$remote_addr [$time_local] "$request" $status';
access_log /var/log/nginx/access.log custom;Thus the log format is custom and the log path is /var/log/nginx/access.log.
(2) Collected Metrics Explanation
(3) View Generated Nginx Monitoring Charts
Using the configured application, host, and URL filters, you can view per‑second request counts, traffic, average response time, status code distribution, and top URLs by average response time.
(4) Configure Alert Rules in the Event Center
In the alert strategy or rule settings, configure notification recipients. Yunzhou Observability provides default rules such as "Average response time of interface requests" and "Excessive 5xx errors within 1 minute" which can be adjusted as needed.
Common Issues
Metrics not exported : May be due to missing log file, insufficient permissions, or log format mismatch with the configured format. Check nginx_parse_errors_total for parsing errors.
Partial metrics missing : Metrics like http_upstream_time_seconds depend on specific log variables (e.g., $upstream_response_time). Ensure these variables are included in Nginx log_format and synchronized with the exporter configuration.
360 Zhihui Cloud Developer
360 Zhihui Cloud is an enterprise open service platform that aims to "aggregate data value and empower an intelligent future," leveraging 360's extensive product and technology resources to deliver platform services to customers.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
