NGINX

Overview

NGINX is an open source web server with a strong focus on high concurrency, performance and low memory usage. It’s one of the most popular web servers on the internet, and can also act as a reverse proxy, a load balancer, or as an HTTP cache.

The SolarWinds Snap Agent allows you to easily monitor the health of your NGINX service(s). It requires that your nginx binary is compiled with the stub_status module enabled.

Note

This integration is currently available for Windows and Linux platforms.

Note

This integration was updated to V2 plugin framework. If you are still using depreciated way of configuring it, please refer to old documentation.

Setup

The nginx monitoring is accomplished by bridge plugin which is included with the SolarWinds Snap Agent by default. Please follow the directions below to enable it for a agent instance. The bridge plugin utilize Telegraf NGINX plugin.

Prerequisites

The NGINX server being monitored must have the stub_status module compiled into its binary. Most distributions have this enabled by default. This can be verified with the following command:

$ nginx -V 2>&1 | grep -o with-http_stub_status_module

Your NGINX server will need a location defined with the stub_status module activated. Here is a sample definition that allows connections from the local agent and works with our default plugin configuration.

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

In addition, you’ll need to adjust the URL setting in the task-bridge-nginx.yaml task file to match your particular setup.

The server blocks of the NGINX config are typically in the supplemental configuration files that are referenced by the master config. Locate the master config with:

$ nginx -t

Open the master configuration file, and search for include near the end of the file. Find the server block in one of the referenced config files and modify it as referenced above, then reload NGINX:

$ nginx -s reload

Configuration

The agent provides an example task file to help you get started quickly, but requires you to provide the correct settings for your NGINX installation. To enable the task:

  1. Make a copy of the NGINX example task file task-bridge-nginx.yaml.example`, renaming it to task-bridge-nginx.yaml:

On Windows, using Explorer or PowerShell:

> copy "C:\ProgramData\SolarWinds\Snap\tasks-autoload.d\task-bridge-nginx.yaml.example" "C:\ProgramData\SolarWinds\Snap\tasks-autoload.d\task-bridge-nginx.yaml"

On Linux using command line:

$ sudo cp /opt/SolarWinds/Snap/etc/tasks-autoload.d/task-bridge-nginx.yaml.example /opt/SolarWinds/Snap/etc/tasks-autoload.d/task-bridge-nginx.yaml
  1. Edit the task file with settings specific to your NGINX install:

Note

If you wish to also collect logs for this service, uncomment the last section in the example task file. For more information on collecting logs, see the logs collector docs.

---
version: 2

schedule:
  type: cron
  interval: "0 * * * * *"

plugins:
  - plugin_name: bridge

    config:
      nginx:
        ## An array of Nginx stub_status URI to gather stats.
        urls:
          - http://localhost/server_status

        ## Optional TLS Config
        # tls_ca: /path/to/cafile
        # tls_cert: /path/to/certfile
        # tls_key: /path/to/keyfile

        ## Use TLS but skip chain & host verification
        # insecure_skip_verify: false

        ## HTTP response timeout (default: 5s)
        response_timeout: "5s"

    publish:
      - plugin_name: publisher-appoptics

## If you want to gather logs for this integration, uncomment the following section.
#  - plugin_name: logs
#    config:
#      sources:
#        log_files:
#          file_paths:
#            - path: /var/log/nginx/access.log
#            - path: /var/log/nginx/error.log

#    publish:
#      - plugin_name: publisher-appoptics
  1. Restart the agent:

On Windows command line:

> net stop swisnapd
> net start swisnapd

On Linux command line:

$ sudo service swisnapd restart
  1. Enable the NGINX integration in AppOptics
On the Integrations Page you will see NGINX integration available if the previous steps were successful. It may take a couple minutes before the NGINX integration is identified. Select the NGINX integration to open the configuration menu in the UI, and enable it. If you do not see it, see Troubleshooting Linux.

Testing Integration

To check if and what metrics can be collected with given configuration, run bridge plugin in debug mode:

On Windows command line:

> "C:\Program Files\SolarWinds\Snap\bin\snap-plugin-collector-bridge.exe" --debug-mode --plugin-config "{\"nginx\": {\"urls\": [\"http://localhost/server_status\"]}}"

On Linux command line:

$ /opt/SolarWinds/Snap/bin/snap-plugin-collector-bridge --debug-mode --plugin-config "{\"nginx\": {\"urls\": [\"http://localhost/server_status\"]}}"

Metrics and Tags

Metrics

The table below lists each of the metrics collected by the NGINX plugin.

Name Description
nginx.accepts Total number of accepted client connections
nginx.active Number of active client connections including waiting connections
nginx.handled Total number of handled connections
nginx.reading Number of connections where nginx is reading the request header
nginx.requests Total number of client requests
nginx.waiting Number of idle connections waiting for a request
nginx.writing Number of connections where nginx is writing the response to the client

Tags

The table below lists each tag available for the NGINX plugin.

Tag Name Description
hostname Name of the host. Instead of using this tag we recommend using the @host alias.
port Port number
server Name of the server