Skip to main content

Nginx - Classic Collector

Thumbnail icon

Nginx is a web server used as a reverse proxy, load balancer, mail proxy, and HTTP cache. The Sumo Logic app for Nginx helps you monitor activity in Nginx. The preconfigured dashboards provide information about site visitors, including the location of visitors, devices/operating systems, and browsers used, and information about server activity, including bots, observed, and error information.

This app is tested with the following Nginx versions:

  • Kubernetes environments: Nginx version 1.21.4
  • Non-Kubernetes environments: Nginx version 1.19.8
Tutorial

Learn to set up NGINX for non-Kubernetes Sources.

Collecting logs for the Nginx app

This section provides instructions for configuring log and metric collection for the Sumo Logic app for Nginx. The following tasks are required:

Step 1: Configure fields in Sumo Logic

As part of the app installation process, the following fields will be created by default:

  • component
  • environment
  • webserver_system
  • webserver_farm
  • pod

Additionally, if you are using Nginx in the Kubernetes environment, the following additional fields will be created by default during the app installation process:

  • pod_labels_component
  • pod_labels_environment
  • pod_labels_webserver_system
  • pod_labels_webserver_farm

Step 2: Configure Nginx Logs and Metrics Collection

Sumo Logic supports the collection of logs and metrics data from Nginx in both Kubernetes and non-Kubernetes environments. Please click on the appropriate links below based on the environment where your Nginx farms are hosted.

In Kubernetes environments, we use the Telegraf Operator, which is packaged with our Kubernetes collection. You can learn more about it here. The diagram below illustrates how data is collected from Nginx in Kubernetes environments. In the architecture shown below, there are four services that make up the metric collection pipeline: Telegraf, Telegraf Operator, Prometheus, and Sumo Logic Distribution for OpenTelemetry Collector.

Web servers

The first service in the pipeline is Telegraf. Telegraf collects metrics from Nginx. Note that we’re running Telegraf in each pod we want to collect metrics from as a sidecar deployment: i.e. Telegraf runs in the same pod as the containers it monitors. Telegraf uses the Nginx input plugin to obtain metrics. For simplicity, the diagram doesn’t show the input plugins. The injection of the Telegraf sidecar container is done by the Telegraf Operator. Prometheus pulls metrics from Telegraf and sends them to Sumo Logic Distribution for OpenTelemetry Collector, which enriches metadata and sends metrics to Sumo Logic.

In the logs pipeline, Sumo Logic Distribution for OpenTelemetry Collector collects logs written to standard out and forwards them to another instance of Sumo Logic Distribution for OpenTelemetry Collector, which enriches metadata and sends logs to Sumo Logic.

Prerequisites

It’s assumed that you are using the latest helm chart version. If not, upgrade using the instructions here.

Configure Metrics Collection

This section explains the steps to collect Nginx metrics from a Kubernetes environment.

In Kubernetes environments, we use the Telegraf Operator, which is packaged with our Kubernetes collection. You can learn more about this here. Follow the steps listed below to collect metrics from a Kubernetes environment:

  1. Set up Kubernetes Collection with the Telegraf Operator.
  2. On your Nginx Pods, add the following annotations:
annotations:
telegraf.influxdata.com/class: sumologic-prometheus
prometheus.io/scrape: "true"
prometheus.io/port: "9273"
telegraf.influxdata.com/inputs: |+

[[inputs.nginx]]
urls = ["http://IP_TO_BE_CHANGED/nginx_status"]
response_timeout = "5s"

[inputs.nginx.tags]
environment="<env_TO_BE_CHANGED>"
component="webserver"
webserver_system="nginx"
webserver_farm="<nginx_TO_BE_CHANGED>"--If you haven’t defined a farm in Nginx, then enter `default` for `webserver_farm`.

Enter in values for the following parameters (marked CHANGEME in the snippet above):

  • telegraf.influxdata.com/inputs. This contains the required configuration for the Telegraf Nginx Input plugin. Please refer to this doc for more information on configuring the Nginx input plugin for Telegraf. Note: As telegraf will be run as a sidecar the host should always be localhost.
    • In the input plugins section, that is [[inputs.nginx]]:
      • urls - An array of Nginx stub_status URI to gather stats. This can be a comma-separated list to connect to multiple Nginx servers. Please see this doc for more information on additional parameters for configuring the Nginx input plugin for Telegraf.
    • In the tags section, [inputs.nginx.tags]
      • environment. This is the deployment environment where the Nginx farm identified by the value of servers resides. For example: dev, prod or qa. While this value is optional we highly recommend setting it.
      • webserver_farm - Enter a name to identify this Nginx farm. This farm name will be shown in the Sumo Logic dashboards.
Do not modify these values

Modifying these values will cause the Sumo Logic apps to not function correctly.

  • telegraf.influxdata.com/class: sumologic-prometheus. This instructs the Telegraf operator what output to use. This should not be changed.
  • prometheus.io/scrape: "true". This ensures our Prometheus will scrape the metrics.
  • prometheus.io/port: "9273". This tells prometheus what ports to scrape on. This should not be changed.
  • telegraf.influxdata.com/inputs
    • In the tags section, that is [inputs.nginx.tags]
      • component: “webserver”: This value is used by Sumo Logic apps to identify application components.
      • webserver_system: “nginx”: This value identifies the webserver system.

For all other parameters, see this doc for more parameters that can be configured in the Telegraf agent globally.

  1. Sumo Logic Kubernetes collection will automatically start collecting metrics from the pods having the labels and annotations defined in the previous step.
  2. Verify metrics in Sumo Logic.

Configure Logs Collection

This section explains the steps to collect Nginx logs from a Kubernetes environment.

  1. (Recommended Method) Add labels on your Nginx pods to capture logs from standard output. Make sure that the logs from Nginx are sent to stdout. Follow the instructions below to capture Nginx logs from stdout on Kubernetes.

    1. Apply following labels to the Nginx pod.
    labels:
    environment="prod_CHANGEME"
    component="webserver"
    webserver_system="nginx"
    webserver_farm="<farm_CHANGEME>"
    1. Enter in values for the following parameters (marked CHANGE_ME above):
    • environment. This is the deployment environment where the Nginx farm identified by the value of servers resides. For example:- dev, prod, or QA. While this value is optional we highly recommend setting it.
    • Webserver_farm - Enter a name to identify this Nginx farm. This farm name will be shown in the Sumo Logic dashboards. If you haven’t defined a farm in Nginx, then enter default for webserver_farm.
    Do not modify these values

    Modifying these values will cause the Sumo Logic apps to not function correctly.

    • component “webserver” - This value is used by Sumo Logic apps to identify application components.
    • webserver_system: “nginx” - This value identifies the database system.

    For all other parameters, see this doc for more parameters that can be configured in the Telegraf agent globally.

    1. The Sumologic-Kubernetes-Collection will automatically capture the logs from stdout and will send the logs to Sumologic. For more information on deploying Sumologic-Kubernetes-Collection, visit here.
    2. Verify logs in Sumo Logic.
  2. (Optional) Collecting Nginx Logs from a Log File. Follow the steps below to capture Nginx logs from a log file on Kubernetes.

    1. Determine the location of the Nginx log file on Kubernetes. This can be determined from the nginx.conf for your nginx farm along with the mounts on the Nginx pods.
    2. Install the Sumo Logic tailing sidecar operator.
    3. Add the following annotation in addition to the existing annotations.
    annotations:
    tailing-sidecar: sidecarconfig;<mount>:<path_of_nginx_log_file>/<Nginx_log_file_name>

    Example:

    annotations:
    tailing-sidecar: sidecarconfig;data:/var/log/nginx/error.log
    1. Make sure that the Nginx pods are running and annotations are applied by using the command:
    kubectl describe pod <nginx_pod_name>
    1. Sumo Logic Kubernetes collection will automatically start collecting logs from the pods having the annotations defined above.
    2. Verify logs in Sumo Logic.

FER to normalize the fields in Kubernetes environments. Labels created in Kubernetes environments automatically are prefixed with pod_labels. To normalize these for our app to work, a Field Extraction Rule named AppObservabilityNginxWebserverFER is automatically created for Nginx Application Components.


Installing the Nginx app

This section demonstrates how to install the Nginx app.

  1. From the App Catalog, search for and select the Nginx app.
  2. Select the version of the service you're using and click Add to Library.
    note

    Version selection is not available for all apps.

  3. To install the app, complete the following fields.
    1. App Name. You can retain the existing name, or enter a name of your choice for the app.
    2. Data Source. Choose Enter a Custom Data Filter, and enter a custom Nginx farm filter. Examples:
      1. For all Nginx farms, webserver_farm=*.
      2. For a specific farm, webserver_farm=nginx.dev.01.
      3. Farms within a specific environment, webserver_farm=nginx.dev.01 and environment=prod. (This assumes you have set the optional environment tag while configuring collection).
  4. Advanced. Select the Location in Library (the default is the Personal folder in the library), or click New Folder to add a new folder.
  5. Click Add to Library.

Once an app is installed, it will appear in your Personal folder, or other folder that you specified. From here, you can share it with your organization.

Panels will start to fill automatically. It's important to note that each panel slowly fills with data matching the time range query and received since the panel was created. Results won't immediately be available, but with a bit of time, you'll see full graphs and maps.

Viewing Nginx Dashboards

Filter with template variables

Template variables provide dynamic dashboards that can rescope data on the fly. As you apply variables to troubleshoot through your dashboard, you view dynamic changes to the data for a quicker resolution to the root cause. You can use template variables to drill down and examine the data on a granular level. For more information, see Filter with template variables.

Overview

The Nginx - Overview dashboard provides an at-a-glance view of the NGINX server access locations, error logs along with connection metrics.

Use this dashboard to:

  • Gain insights into originated traffic location by region. This can help you allocate computer resources to different regions according to their needs.
  • Gain insights into your Nginx health using Critical Errors and Status of Nginx Server.
  • Get insights into Active and dropped connection.
Nginx-Overview

Error Logs

The Nginx - Error Logs Analysis dashboard provides a high-level view of log level breakdowns, comparisons, and trends. The panels also show the geographic locations of clients and clients with critical messages, new connections and outliers, client requests, request trends, and request outliers.

Use this dashboard to:

  • Track requests from clients. A request is a message asking for a resource, such as a page or an image.
  • Track and view client geographic locations generating errors.
  • Track critical alerts and emergency error alerts.
Nginx-Error-Logs

The Nginx - Logs Timeline Analysis dashboard provides a high-level view of the activity and health of Nginx servers on your network. Dashboard panels display visual graphs and detailed information on traffic volume and distribution, responses over time, as well as time comparisons for visitor locations and server hits.

Use this dashboard to:

  • To understand the traffic distribution across servers, provide insights for resource planning by analyzing data volume and bytes served.
  • Gain insights into originated traffic location by region. This can help you allocate compute resources to different regions according to their needs.
Nginx-Trends

Outlier Analysis

The Nginx - Outlier Analysis dashboard provides a high-level view of Nginx server outlier metrics for bytes served, number of visitors, and server errors. You can select the time interval over which outliers are aggregated, then hover the cursor over the graph to display detailed information for that point in time.

Use this dashboard to:

  • Detect outliers in your infrastructure with Sumo Logic’s machine learning algorithm.
  • To identify outliers in incoming traffic and the number of errors encountered by your servers.

You can use schedule searches to send alerts to yourself whenever there is an outlier detected by Sumo Logic.

Nginx-Outlier-Analysis

Threat Intel

The Nginx - Threat Intel dashboard provides an at-a-glance view of threats to Nginx servers on your network. Dashboard panels display the threat count over a selected time period, geographic locations where threats occurred, source breakdown, actors responsible for threats, severity, and a correlation of IP addresses, method, and status code of threats.

Use this dashboard to:

  • To gain insights and understand threats in incoming traffic and discover potential IOCs. Incoming traffic requests are analyzed using Sumo Logic threat intelligence.
Nginx-Threat-Intel

Web Server Operations

The Nginx - Web Server Operations dashboard provides a high-level view combined with detailed information on the top ten bots, geographic locations, and data for clients with high error rates, server errors over time, and non 200 response code status codes. Dashboard panels also show information on server error logs, error log levels, error responses by a server, and the top URIs responsible for 404 responses.

Use this dashboard to:

  • Gain insights into Client, Server Responses on Nginx Server. This helps you identify errors in Nginx Server.
  • To identify geo-locations of all Client errors. This helps you identify client location causing errors and helps you to block client IPs.
Nginx-WebServerOperations

Visitor Access Types

The Nginx - Visitor Access Types dashboard provides insights into visitor platform types, browsers, and operating systems, as well as the most popular mobile devices, PC and Mac versions used.

Use this dashboard to:

  • Understand which platform and browsers are used to gain access to your infrastructure.
  • These insights can be useful for planning in which browsers, platforms, and operating systems (OS) should be supported by different software services.
Nginx-VisitorAccessTypes

Visitor Locations

The Nginx - Visitor Locations dashboard provides a high-level view of Nginx visitor geographic locations both worldwide and in the United States. Dashboard panels also show graphic trends for visits by country over time and visits by US region over time.

Use this dashboard to:

  • Gain insights into geographic locations of your user base. This is useful for resource planning in different regions across the globe.
Nginx-VisitorLocations

Visitor Traffic Insight

The Nginx - Visitor Traffic Insight dashboard provides detailed information on the top documents accessed, top referrers, top search terms from popular search engines, and the media types served.

Use this dashboard to:

  • To understand the type of content that is frequently requested by users.
  • It helps in allocating IT resources according to the content types.
Nginx-VisitorTrafficInsight

Connections and Requests Metrics

The Nginx - Connections and Requests Metrics dashboard provides insight into active, dropped connections, reading, writing, and waiting requests.

Use this dashboard to:

  • Gain information about active and dropped connections. This helps you identify the connection rejected by Nginx Server.
  • Gain information about the total requests handled by Nginx Server per second. This helps you understand read, write requests on Nginx Server.
Nginx-Connections-and-Requests

Installing Nginx monitors

note

To view the full list, see Nginx.

Nginx Alerts

Sumo Logic has provided out-of-the-box alerts available through Sumo Logic monitors to help you quickly determine if the Nginx server is available and performing as expected. These alerts are built based on logs and metrics datasets and have preset thresholds based on industry best practices and recommendations. They are as follows:

Alert Type (Metrics/Logs)Alert NameAlert DescriptionTrigger Type (Critical / Warning)Alert ConditionRecover Condition
LogsNginx - Access from Highly Malicious SourcesThis alert fires when an Nginx server is accessed from highly malicious IP addresses.Critical> 0< = 0
LogsNginx - High Client (HTTP 4xx) Error RateThis alert fires when there are too many HTTP requests (>5%) with a response status of 4xx.Critical> 00
LogsNginx - High Server (HTTP 5xx) Error RateThis alert fires when there are too many HTTP requests (>5%) with a response status of 5xx.Critical> 00
LogsNginx - Critical Error MessagesThis alert fires when we detect critical error messages for a given Nginx server.Critical> 00
MetricsNginx - Dropped ConnectionsThis alert fires when we detect dropped connections for a given Nginx server.Critical> 00
Status
Legal
Privacy Statement
Terms of Use

Copyright © 2025 by Sumo Logic, Inc.