openresty-prometheus is a module to monitor the Nginx web server and reverse-proxy using Prometheus and Grafana. This tool allows you to collect and visualize various Nginx metrics to ensure your server is running optimally.
- nginx_http_requests_total: Number of HTTP requests with hostname, HTTP status, request method, and cache status.
- nginx_http_request_duration_seconds: HTTP request latency with hostname.
- nginx_http_connections: Number of HTTP connections with statuses like active, reading, waiting, and writing.
- Docker
- Docker Compose
- Nginx
- Prometheus
- Grafana
Follow these instructions to get a copy of the project up and running on your local machine for development and testing purposes.
- Clone the repository:
git clone https://github.com/srajasimman/openresty-prometheus.git
cd openresty-prometheus
- Build the Docker image:
docker build -t openresty-prometheus .
- Run the Docker container:
docker run -d -p 80:80 -p 9145:9145 openresty-prometheus
- Update your Nginx configuration to include the Prometheus configuration. Replace the default configuration file with the
prometheus.conf
provided in this repository.
cp prometheus.conf /etc/nginx/conf.d/
- Ensure the Prometheus scrape configuration includes the Nginx metrics endpoint:
scrape_configs:
- job_name: 'nginx'
static_configs:
- targets: ['<nginx-server-ip>:9145']
Once your Docker container is running, you can access the metrics at:
curl -s "http://<your-server-ip>:9145/metrics"
- Add Prometheus as a data source in Grafana.
- Import or create dashboards using the collected Nginx metrics:
nginx_http_requests_total
nginx_http_request_duration_seconds
nginx_http_connections
- Description: Total number of HTTP requests.
- Labels: hostname, status, method, cache_status
- Description: Duration of HTTP requests in seconds.
- Labels: hostname
- Description: Current number of HTTP connections.
- Labels: status (active, reading, waiting, writing)
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project.
- Create your Feature Branch (git checkout -b feature/AmazingFeature).
- Commit your Changes (git commit -m 'Add some AmazingFeature').
- Push to the Branch (git push origin feature/AmazingFeature).
- Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.
For more details, visit the openresty-prometheus repository.
Feel free to reach out if you have any questions or need further assistance!
Happy monitoring!