Monitor Nginx with CollectD, InfluxDB and Grafana

Monitor is the best solution to know your system is working well or not.  If your system is complicated,  you will have many things need to be monitored. In this post, I just show you a simple way to monitor Nginx with CollectD, InfluxDB and Grafana.

Before reading this post, make sure that you are take a look Monitor server with CollectD, InfluxDB and Grafana to get started with CollectD, InfluxDB and Grafana.

Nginx

To monitor Nginx, your nginx have to be enabled http_stub_status_module. At the first, you should check your Nginx contains http_stub_status_module or not by command:

In the default, if you are using Ubuntu 14.04, and install nginx by apt-get command, then you do not worry about the step above.

And now, you should change nginx config with the content below:

And restart your nginx:

Now, you can get nginx status by url http://127.0.0.1/nginx_status:

The output should be:

CollectD

In the next step, we will enable Nginx plugin of CollectD in /opt/collectd/etc/collectd.conf:

Restart your CollectD:

InfluxDB

After restarting CollectD, you wait a minute then checking InfluxDB to make sure that Nginx monitor data is stored.

Grafana

In the last step, we create a Graph Panel in Grafana to monitor how many “requests per second” . And Switch editor Mode to input the query below:

If you do not know how to “Switch editor mode”, you should see the image below:

14-01-2016 9-17-47 SA

Grafana – Switch editor mode

Finally, you will get the graph below:

13-01-2016 10-17-47 SA

Nginx – Request Per Second

You can also use data stored in InfluxDB to create the output by your way.