Monitoring nginx with collectd

Follow this guide to fetch Nginx performance metrics with collectd for monitoring, graphing and alerting purposes.

Nginx Connection States Monitoring

Nginx Request Monitoring

We use the nginx collectd plugin to fetch these metrics from a running nginx instance. This plugin is included by default in our collectd distribution so no additional installation is required.

Note that your nginx binary must be compiled with support for the stub_status module to be able to use this feature. Most distributions include this by default. You can verify yours by running the following command:

nginx -V 2>&1 | grep -q with-http_stub_status && echo ALL GOOD

All good? OK, now you need to configure your nginx instance (or instances) to expose its status report over HTTP, so add this snippet to your nginx config file / directory:

location /nginx_status {
    stub_status on;
    access_log off;
    allow 127.0.0.1;
    deny all;
}

Then you just need to place monitor-nginx.conf in your collectd additional config directory; for example /opt/wormly/collectd/etc/collectd.d/. You will probably need to edit this file to specify the HTTP listening port of your nginx instance.

LoadPlugin nginx
<Plugin "nginx">
    URL "http://localhost:8080/nginx_status"
</Plugin>

Test your collectd configuration:

collectd-wormly -T

No errors and {"ok":true} shown on the console? Reload the daemon to commence data collection:

service collectd-wormly restart

Downtime Hurts. Start monitoring and stop worrying.

Our monitoring service continually tests your servers & web sites to keep you online and performing fast. Fully-featured plans start from just $25 / month.

But don't listen to our spiel - Decide for yourself with a free trial »