Using New Relic to Monitor Nginx. Here’s how.

Back in 2013 New Relic introduced Plugin Central, where New Relic’s partners, third-party vendors, and users can publish plugin agents that collect selected metric data, and users can install and view the plugin data on their dashboards as a set of summary metrics, charts, and tables.

This allows you to use a single platform to monitor critical information about your application stacks, tools, interfaces, logins, alerts, and other data, and view everything from a single user interface:

nginx new relic plugin

You can now visualize Nginx web server load and performance with this Nginx plugin provided by the original authors of Nginx. Collect and display key load metrics to track your nginx instances behavior.

The Nginx New Relic plugin allows to collect and report various important counters such as:

  • Active client connections
  • Idle (keepalive) client connections
  • Client connections accept/drop rate
  • Average client requests per second


Installing NewRelic Nginx Plugin on your Server


To use this plugin, you must have the following:

  • Ruby
  • bundler for Ruby
  • at least one running NGINX instance with ngx_http_stub_status module: (enabled by default on Nginx package installs)
  • a New Relic account

Installation and running

  1. Download the Nginx web server plugin .tar.gz from here.
  2. Unpack the .tar.gz file in a new directory. (eg. /usr/src/nrplugins/)
  3. Run bundle install to install all needed prerequisites.
    If that returns “bundle: command not found” you can fix adding the rubygems path to your $PATH variable. Use command gem environment to find the “executable directory” and export PATH=$PATH:/var/lib/gems/1.8/bin (replace “/var/lib/gems/1.8/bin” with the executable directory path)
  4. From within the unpacked directory, copy the config/ file to config/newrelic_plugin.yml.
  5. Insert your New Relic license key into config/newrelic_plugin.yml.
  6. Add a special stub_status location to your nginx configuration file, e.g.:
    server {
    server_name localhost;
    location = /nginx_stub_status {
    stub_status on;
    deny all;
  7. Run ./newrelic_nginx_agent.daemon start to start the agent in daemon mode.

By default the plugin name will be “localhost” change this in the config/newrelic_plugin.yml and also change “server_name” in the Nginx config above to be the same.

More installation and configuration details are included at the end of the README.txt file packaged with the plugin.

More screenshots from my New Relic account:

nginx new relic plugin


nginx new relic plugin

Tags: ,

Top ↑