---
id: nginx
title: Nginx - Classic Collector
sidebar_label: Nginx
description: Provides searches and Dashboards that monitor log events generated by Nginx servers.
slug: /help/docs/integrations/web-servers/nginx/
canonical: https://www.sumologic.com/help/docs/integrations/web-servers/nginx/
---
import useBaseUrl from '@docusaurus/useBaseUrl';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
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
import Iframe from 'react-iframe';
:::training Tutorial
Learn to set up NGINX for non-Kubernetes Sources.
:::
## Configure Nginx logs and metrics collection
This section provides instructions for configuring log and metric collection for the Sumo Logic app for Nginx. The following tasks are required:
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](/docs/send-data/collect-from-other-data-sources/collect-metrics-telegraf/telegraf-collection-architecture). 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](https://github.com/SumoLogic/sumologic-otel-collector).
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](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nginx) 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](https://github.com/SumoLogic/sumologic-otel-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.
:::note Prerequisites
It’s assumed that you are using the latest helm chart version. If not, upgrade using the instructions [here](/docs/send-data/kubernetes).
:::
### 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](/docs/send-data/collect-from-other-data-sources/collect-metrics-telegraf/telegraf-collection-architecture). Follow the steps listed below to collect metrics from a Kubernetes environment:
1. [Set up Kubernetes Collection with the Telegraf Operator](/docs/send-data/collect-from-other-data-sources/collect-metrics-telegraf/install-telegraf).
2. On your Nginx Pods, add the following annotations:
```sql
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=""
component="webserver"
webserver_system="nginx"
webserver_farm=""--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](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/redis) 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](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nginx#nginx-input-plugin) 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.
:::warning 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](/docs/send-data/collect-from-other-data-sources/collect-metrics-telegraf/install-telegraf#configuring-telegraf) for more parameters that can be configured in the Telegraf agent globally.
3. Sumo Logic Kubernetes collection will automatically start collecting metrics from the pods having the labels and annotations defined in the previous step.
4. 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 the following labels to the Nginx pod.
```sql
labels:
environment="prod_CHANGEME"
component="webserver"
webserver_system="nginx"
webserver_farm=""
```
2. 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`.
:::warning 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](/docs/send-data/collect-from-other-data-sources/collect-metrics-telegraf/install-telegraf#configuring-telegraf) for more parameters that can be configured in the Telegraf agent globally.
3. 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](/docs/integrations/containers-orchestration/kubernetes#collecting-metrics-and-logs-for-the-kubernetes-app) here.
4. 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](https://github.com/SumoLogic/tailing-sidecar/tree/main/operator#deploy-tailing-sidecar-operator).
3. Add the following annotation in addition to the existing annotations.
```xml
annotations:
tailing-sidecar: sidecarconfig;:/
```
Example:
```sql
annotations:
tailing-sidecar: sidecarconfig;data:/var/log/nginx/error.log
```
4. Make sure that the Nginx pods are running and annotations are applied by using the command:
```bash
kubectl describe pod
```
5. Sumo Logic Kubernetes collection will automatically start collecting logs from the pods having the annotations defined above.
6. 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.
Sumo Logic uses the Telegraf operator for Nginx metric collection and the [Installed Collector](/docs/send-data/installed-collectors) for collecting Nginx logs. The diagram below illustrates the components of the Nginx collection in a non-Kubernetes environment.
Telegraf uses the[ Nginx input plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nginx) to obtain Nginx metrics and the Sumo Logic output plugin to send the metrics to Sumo Logic. Logs from Nginx are collected by a [Local File Source](/docs/send-data/installed-collectors/sources/local-file-source).
The process to set up collection for Nginx data is done through the following steps.
### Configure metrics collection
#### Set up a Sumo Logic HTTP source
1. **Configure a Hosted Collector for Metrics.** To create a new Sumo Logic hosted collector, perform the steps in the [Create a Hosted Collector](/docs/send-data/hosted-collectors/configure-hosted-collector) documentation.
2. **Configure an HTTP Logs & Metrics source**:
1. On the created Hosted Collector on the Collection Management screen, select **Add Source**.
2. Select **HTTP Logs & Metrics.**
1. **Name.** (Required). Enter a name for the source.
2. **Description.** (Optional).
3. **Source Category** (Recommended). Be sure to follow the [Best Practices for Source Categories](/docs/send-data/best-practices). A recommended Source Category may be Prod/Webserver/Nginx/Metrics.
3. Select **Save**.
4. Take note of the URL provided once you click _Save_. You can retrieve it again by selecting the **Show URL** next to the source on the Collection Management screen.
### Configure logs collection
The Nginx app supports the default access logs and error logs format.
1. **Configure logging in Nginx.** Before you can configure Sumo Logic to ingest logs, you must configure the logging of errors and processed requests in NGINX Open Source and NGINX Plus. For instructions, refer to the following [documentation](https://docs.nginx.com/nginx/admin-guide/monitoring/logging/)
2. **Configure an Installed Collector.** If you have not already done so, install and configure an installed collector for Windows by [following the documentation](/docs/send-data/installed-collectors/windows).
3. **Configure a Collector** Use one of the following Sumo Logic Collector options:
1. To collect logs directly from the Nginx machine, configure an [Installed Collector](/docs/send-data/installed-collectors).
2. If you're using a service like Fluentd, or you would like to upload your logs manually, [Create a Hosted Collector](/docs/send-data/hosted-collectors/configure-hosted-collector).
4. **Configure a local file source**. Choose a method:
For an Installed Collector
To collect logs directly from your Nginx machine, use an Installed Collector and a Local File Source.
1. Add a [Local File Source](/docs/send-data/installed-collectors/sources/local-file-source).
2. Configure the Local File Source fields as follows:
* **Name**. (Required)
* **Description**. (Optional)
* **File Path (Required)**. Enter the path to your error.log or access.log. The files are typically located in /var/log/nginx/error.log. If you're using a customized path, check the **nginx.conf** file for this information. If you're using Passenger, you may have instructed Passenger to log to a specific log using the passenger_log_file option.
* **Source Host**. Sumo Logic uses the hostname assigned by the OS unless you enter a different hostname.
* **Source Category**. Enter any string to tag the output collected from this Source, such as Nginx/Access or Nginx/Error. (The Source Category metadata field is a fundamental building block to organize and label Sources. For details, see [Best Practices](/docs/send-data/best-practices).)
* **Fields.** Add the following fields, as shown in the screenshot below.
```bash
component = webserver
webserver_system = nginx
webserver_farm = #Use Default if you do not have one.
environment = #i.e., Dev, QA, or Prod
```
3. Configure the Advanced section:
* Enable Timestamp Parsing. Select Extract timestamp information from log file entries.
* Time Zone. Automatically detect.
* Timestamp Format. The timestamp format is automatically detected.
* Encoding. Select UTF-8 (Default).
* Enable Multiline Processing.
* Error logs. Select Detect messages spanning multiple lines and Infer Boundaries - Detect message boundaries automatically.
* Access logs. These are single-line logs, uncheck Detect messages spanning multiple lines.
4. Click Save.
For a Hosted Collector
If you're using a service like Fluentd, or you would like to upload your logs manually, use a Hosted Collector and an HTTP Source.
1. Add an [HTTP Source](/docs/send-data/hosted-collectors/http-source/logs-metrics).
2. Configure the HTTP Source fields as follows:
* **Name**. (Required)
* **Description**. (Optional)
* **Source Host**. Sumo Logic uses the hostname assigned by the OS unless you enter a different hostname.
* **Source Category**. Enter any string to tag the output collected from this Source, such as Nginx/Access or Nginx/Error. (The Source Category metadata field is a fundamental building block to organize and label Sources. For details, see [Best Practices](/docs/send-data/best-practices).)
3. Configure the **Advanced** section:
* **Enable Timestamp Parsing**. Select **Extract timestamp information from log file entries**.
* **Time Zone**. For Access logs, use the time zone from the log file. For Error logs, make sure to select the correct time zone.
* **Timestamp Format**. The timestamp format is automatically detected.
* **Enable Multiline Processing**.
* **Error logs**: Select **Detect messages spanning multiple lines** and **Infer Boundaries - Detect message boundaries automatically**.
* **Access logs**: These are single-line logs, uncheck **Detect messages spanning multiple lines**.
4. Click **Save**.
5. When the URL associated with the HTTP Source is displayed, copy the URL so you can add it to the service you are using, such as Fluentd.
#### Set up Telegraf
1. **Install Telegraf if you haven’t already.** Use the [following steps](/docs/send-data/collect-from-other-data-sources/collect-metrics-telegraf/install-telegraf) to install Telegraf.
2. **Configure and start Telegraf.**
3. As part of collecting metrics data from Telegraf, we will use the [nginx input plugin](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nginx) to get data from Telegraf and the [Sumo Logic output plugin](https://github.com/SumoLogic/fluentd-output-sumologic) to send data to Sumo Logic.
Create or modify `telegraf.conf` and copy and paste the text below:
```sql
[[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=""
[[outputs.sumologic]]
url = ""
data_format = "prometheus"
```
Enter values for fields annotated with `` to the appropriate values. Do not include the brackets (`< >`) in your final configuration
* Input plugins section, which is `[[inputs.nginx]]`:
* `urls` - An array of Nginx stub_status URI to gather stats. For more information on additional parameters to configure the Nginx input plugin for Telegraf see[this doc](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/nginx#nginx-input-plugin).
* In the tags section, which is `[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 on our dashboards.
* In the output plugins section, which is `[[outputs.sumologic]]`:
* **`URL`** - This is the HTTP source URL created previously. See this doc for more information on additional parameters for configuring the Sumo Logic Telegraf output plugin.
Here’s an explanation for additional values set by this Telegraf configuration.
If you haven’t defined a farm in Nginx, then enter `default` for `webserver_farm`.
There are additional values set by the Telegraf configuration. We recommend not modifying these values as they might cause the Sumo Logic app to not function correctly.
* `data_format: “prometheus”`. In the output `[[outputs.sumologic]]` plugins section. Metrics are sent in the Prometheus format to Sumo Logic.
* `Component - “webserver”` - In the input `[[inputs.nginx]]` plugins section. This value is used by Sumo Logic apps to identify application components.
* `webserver_system - “nginx”` - In the input plugins sections. This value identifies the webserver system.
See [this doc](https://github.com/influxdata/telegraf/blob/master/etc/logrotate.d/telegraf) for all other parameters that can be configured in the Telegraf agent globally.
After you have finalized your `telegraf.conf` file, you can start or reload the telegraf service using instructions from this[ doc](https://docs.influxdata.com/telegraf/v1.17/introduction/getting-started/#start-telegraf-service).
At this point, Telegraf should start collecting the Nginx metrics and forward them to the Sumo Logic HTTP Source.
## Installing the Nginx app
import AppInstall2 from '../../reuse/apps/app-install-sc-k8s.md';
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`
## Viewing Nginx Dashboards
import ViewDashboards from '../../reuse/apps/view-dashboards.md';
### Overview
The **Nginx - Overview** dashboard provides an at-a-glance view of the NGINX server access locations, error logs, and 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 connections.
### 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, 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.
### Trends
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.
### 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.
### 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](/docs/security/threat-intelligence/).
### 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 and Server Responses on the Nginx Server. This helps you identify errors in the 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.
### 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.
### 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 the geographic locations of your user base. This is useful for resource planning in different regions across the globe.
### 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.
### 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 the Nginx Server.
* Gain information about the total requests handled by Nginx Server per second. This helps you understand read, and write requests on the Nginx Server.
## Create monitors for Nginx app
import CreateMonitors from '../../reuse/apps/create-monitors.md';
## Nginx alerts
Here are the alerts available for Nginx (click to expand).
| Alert Type (Metrics/Logs) | Alert Name | Alert Description | Trigger Type (Critical / Warning) | Alert Condition | Recover Condition |
|:---|:---|:---|:---|:---|:---|
| Logs | Nginx - Access from Highly Malicious Sources | This alert fires when a Nginx server is accessed from highly malicious IP addresses. | Critical | > 0 | < = 0 |
| Logs | Nginx - High Client (HTTP 4xx) Error Rate | This alert fires when there are too many HTTP requests (>5%) with a response status of 4xx. | Critical | > 0 | 0 |
| Logs | Nginx - High Server (HTTP 5xx) Error Rate | This alert fires when there are too many HTTP requests (>5%) with a response status of 5xx. | Critical | > 0 | 0 |
| Logs | Nginx - Critical Error Messages | This alert fires when we detect critical error messages for a given Nginx server. | Critical | > 0 | 0 |
| Metrics | Nginx - Dropped Connections | This alert fires when we detect dropped connections for a given Nginx server. | Critical | > 0 | 0 |