Repository navigation
v1.0.0 - NGINX Metrics Exporter
Overview
This release transforms lua-resty-ngxstats into a production-ready NGINX metrics exporter with Prometheus format support, comprehensive testing, CI/CD, and complete documentation.
🚨 Breaking Changes
The /status endpoint now outputs Prometheus text format instead of JSON.
Migration
Before (JSON):
curl http://localhost:8080/status | jq '.'After (Prometheus):
curl http://localhost:8080/statusPrometheus Configuration:
scrape_configs:
- job_name: 'nginx'
static_configs:
- targets: ['localhost:8080']
metrics_path: '/status'✨ Highlights
New Features
- ✅ Prometheus text exposition format with HELP and TYPE comments
- ✅ Cache metrics - Track HIT, MISS, BYPASS, EXPIRED, STALE, UPDATING, REVALIDATED
- ✅ HTTP method tracking - Monitor GET, POST, PUT, DELETE, etc.
- ✅ 50+ unit tests with busted framework
- ✅ GitHub Actions CI/CD - Automated linting, testing, and Docker builds
- ✅ Complete documentation - README, CONTRIBUTING, CHANGELOG
Critical Bug Fixes
- 🐛 Fixed crash from undefined
response.exit()in status.lua - 🐛 Fixed
requests.totalmetric using wrong variable - 🐛 Fixed nginx.conf ACL logic error
- 🐛 Added comprehensive error handling to shared memory operations
Code Quality Improvements
- 🧹 Removed all dead and commented-out code
- 🧹 Fixed global variables (converted all to
local) - 🧹 Converted all scripts to proper testable modules
- 🧹 Added input validation with safe conversion helpers
- 🧹 Added comprehensive function documentation
- 🧹 luacheck linting support
📊 Metrics Collected
Connection Metrics
nginx_connections_active(gauge)nginx_connections_accepted(counter)nginx_connections_handled(counter)nginx_connections_reading(gauge)nginx_connections_writing(gauge)nginx_connections_idle(gauge)
Request Metrics
nginx_requests_total(counter)nginx_requests_current(gauge)
Server Zone Metrics
nginx_server_zone_requests_total{zone}(counter)nginx_server_zone_bytes_received{zone}(counter)nginx_server_zone_bytes_sent{zone}(counter)nginx_server_zone_responses_total{zone,status}(counter)nginx_server_zone_methods_total{zone,method}(counter) ⭐ NEWnginx_server_zone_cache_total{zone,cache_status}(counter) ⭐ NEW
Upstream Metrics
nginx_upstream_requests_total{upstream}(counter)nginx_upstream_response_time_seconds{upstream}(counter)nginx_upstream_connect_time_seconds{upstream}(counter)nginx_upstream_queue_time_seconds{upstream}(counter)nginx_upstream_bytes_sent{upstream}(counter)nginx_upstream_bytes_received{upstream}(counter)nginx_upstream_responses_total{upstream,status}(counter)nginx_upstream_server_info{upstream,server}(gauge)
🚀 Quick Start
Docker (Recommended)
# Build and run
make build
make run_dev
# Generate test traffic
./test.sh
# View metrics
curl http://localhost:8080/statusManual Installation
http {
lua_shared_dict ngx_stats 10m;
lua_package_path '/etc/nginx/lua/?.lua;;';
init_by_lua_file /etc/nginx/lua/stats/init.lua;
server {
log_by_lua_file /etc/nginx/lua/stats/log.lua;
}
server {
listen 8080;
location /status {
content_by_lua_file /etc/nginx/lua/stats/show.lua;
}
access_by_lua_file /etc/nginx/lua/stats/status.lua;
}
}📈 Performance
- Overhead: < 1% CPU per request
- Memory: ~200 bytes per unique metric
- Latency: < 1ms added to request processing
📚 Documentation
- README - Complete installation and usage guide
- CONTRIBUTING - Development guide
- CHANGELOG - Detailed change history
🙏 Thanks
Thank you to everyone who has used and supported this project!
Full Changelog: e263311...v1.0.0