---
title: Nginx
description: Monitor connection and request metrics. Get more metrics with NGINX Plus.
breadcrumbs: Docs > Integrations > Nginx
---

# Nginx
Supported OS Integration version9.3.0


## Overview{% #overview %}

The Datadog Agent can collect many metrics from NGINX instances, including (but not limited to)::

- Total requests
- Connections, such as accepted, handled, and active

For users of NGINX Plus, the commercial version of NGINX, the Agent can collect the significantly more metrics that NGINX Plus provides, like:

- Errors, such as 4xx codes and 5xx codes
- Upstream servers, such as active connections, 5xx codes, and health checks
- Caches, such as size, hits, and misses
- SSL, such as handshakes and failed handshakes

**Minimum Agent version:** 6.0.0

## Setup{% #setup %}

### Installation{% #installation %}

The NGINX check pulls metrics from a local NGINX status endpoint, so your `nginx` binaries need to be compiled with a NGINX status module:

- [Stub status module](https://nginx.org/en/docs/http/ngx_http_stub_status_module.html) - for open source NGINX
- [HTTP status module](https://nginx.org/en/docs/http/ngx_http_status_module.html) - only for NGINX Plus

#### NGINX open source{% #nginx-open-source %}

If you use open source NGINX, your instances may lack the stub status module. Verify that your `nginx` binary includes the module before proceeding to **Configuration**:

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

If the command output does not include `http_stub_status_module`, you must install an NGINX package that includes the module. You *can* compile your own NGINX-enabling the module as you compile it-but most modern Linux distributions provide alternative NGINX packages with various combinations of extra modules built in. Check your operating system's NGINX packages to find one that includes the stub status module.

#### NGINX Plus{% #nginx-plus %}

NGINX Plus packages prior to release 13 include the http status module. For NGINX Plus release 13 and above, the status module is deprecated and you must use the new Plus API instead. See [the announcement](https://www.nginx.com/blog/nginx-plus-r13-released) for more information.

#### Prepare NGINX{% #prepare-nginx %}

{% tab title="Host" %}
On each NGINX server, create a `status.conf` file in the directory that contains your other NGINX configuration files, such as `/etc/nginx/conf.d/`.

```
server {
  listen 81;
  server_name localhost;

  access_log off;
  allow 127.0.0.1;
  deny all;

  location /nginx_status {
    # Choose your status module

    # freely available with open source NGINX
    stub_status;

    # for open source NGINX < version 1.7.5
    # stub_status on;

    # available only with NGINX Plus
    # status;

    # ensures the version information can be retrieved
    server_tokens on;
  }
}
```

**NGINX Plus**

NGINX Plus users can also use `stub_status`, but since that module provides fewer metrics, Datadog recommends using `status`.

For NGINX Plus releases 15+, the `status` module is deprecated. Use the [http_api_module](https://nginx.org/en/docs/http/ngx_http_api_module.html) instead. For example, enable the `/api` endpoint in your main NGINX configuration file (`/etc/nginx/conf.d/default.conf`):

```
server {
  listen 8080;
  location /api {
    api write=on;
  }
}
```

To get more detailed metrics with NGINX Plus (such as 2xx / 3xx / 4xx / 5xx response counts per second), set a `status_zone` on the servers you want to monitor. For example:

```
server {
  listen 80;
  status_zone <ZONE_NAME>;
  ...
}
```

Reload NGINX to enable the status or API endpoint. There's no need for a full restart.

```shell
sudo nginx -t && sudo nginx -s reload
```

{% /tab %}

{% tab title="Kubernetes" %}
Add the following snippet to your configuration ConfigMaps to expose the metrics endpoint in a different port:

```yaml
kind: ConfigMap
metadata:
  name: nginx-conf
data:
[...]
  status.conf: |
    server {
      listen 81;

      location /nginx_status {
        stub_status on;
      }

      location / {
        return 404;
      }
    }
```

Then, in your NGINX pod, expose the `81` endpoint and mount that file in the NGINX configuration folder:

```yaml
spec:
  containers:
    - name: nginx
      ports:
        - containerPort: 81
      volumeMounts:
        - mountPath: /etc/nginx/conf.d/status.conf
          subPath: status.conf
          readOnly: true
          name: "config"
  volumes:
    - name: "config"
      configMap:
          name: "nginx-conf"
```

{% /tab %}

### Configuration{% #configuration %}

{% tab title="Host" %}
#### Host{% #host %}

To configure this check for an Agent running on a host:

##### Metric collection{% #metric-collection %}

1. Set the `nginx_status_url` parameter to `http://localhost:81/nginx_status/` in your `nginx.d/conf.yaml` file to start gathering your NGINX metrics. See the [sample nginx.d/conf.yaml](https://github.com/DataDog/integrations-core/blob/master/nginx/datadog_checks/nginx/data/conf.yaml.example) for all available configuration options.

**NGINX Plus**:

   - For NGINX Plus releases 13+, set the parameter `use_plus_api` to `true` in your `nginx.d/conf.yaml` configuration file.

   - Stream stats API calls are included by default for NGINX Plus. If you want to disable them, set the parameter `use_plus_api_stream` to `false` in your `nginx.d/conf.yaml` configuration file.

   - If you are using `http_api_module`, set the parameter `nginx_status_url` to the server's `/api` location in your `nginx.d/conf.yaml` configuration file, for example:

     ```yaml
     nginx_status_url: http://localhost:8080/api
     ```

1. Optional - If you are using the NGINX `vhost_traffic_status module`, set the parameter `use_vts` to `true` in your `nginx.d/conf.yaml` configuration file.

1. [Restart the Agent](https://docs.datadoghq.com/agent/guide/agent-commands/#start-stop-and-restart-the-agent) to start sending NGINX metrics to Datadog.

##### Log collection{% #log-collection %}

*Available for Agent versions >6.0*

1. Collecting logs is disabled by default in the Datadog Agent, enable it in your `datadog.yaml` file:

   ```yaml
   logs_enabled: true
   ```

1. Add this configuration block to your `nginx.d/conf.yaml` file to start collecting your NGINX Logs:

   ```yaml
   logs:
     - type: file
       path: /var/log/nginx/access.log
       service: nginx
       source: nginx
   
     - type: file
       path: /var/log/nginx/error.log
       service: nginx
       source: nginx
   ```

Change the `service` and `path` parameter values and configure them for your environment. See the [sample nginx.d/conf.yaml](https://github.com/DataDog/integrations-core/blob/master/nginx/datadog_checks/nginx/data/conf.yaml.example) for all available configuration options.

1. [Restart the Agent](https://docs.datadoghq.com/agent/guide/agent-commands/#start-stop-and-restart-the-agent).

**Note**: The default NGINX log format does not have a request response time. To include it into your logs, update the NGINX log format by adding the following configuration block in the `http` section of your NGINX configuration file (`/etc/nginx/nginx.conf`):

```gdscript3
http {
	#recommended log format
	log_format nginx '\$remote_addr - \$remote_user [\$time_local] '
                  '"\$request" \$status \$body_bytes_sent \$request_time '
                  '"\$http_referer" "\$http_user_agent"';

	access_log /var/log/nginx/access.log;
}
```

{% /tab %}

{% tab title="Docker" %}
#### Docker{% #docker %}

To configure this check for an Agent running on a container:

##### Metric collection{% #metric-collection %}

Set [Autodiscovery Integration Templates](https://docs.datadoghq.com/agent/docker/integrations/?tab=docker) as Docker labels on your application container:

```yaml
LABEL "com.datadoghq.ad.check_names"='["nginx"]'
LABEL "com.datadoghq.ad.init_configs"='[{}]'
LABEL "com.datadoghq.ad.instances"='[{"nginx_status_url": "http://%%host%%:81/nginx_status/"}]'
```

**Note**: This instance configuration works only with NGINX Open Source. If you are using NGINX Plus, inline the corresponding instance configuration.

#### Log collection{% #log-collection %}

Collecting logs is disabled by default in the Datadog Agent. To enable it, see [Docker Log Collection](https://docs.datadoghq.com/agent/docker/log/?tab=containerinstallation#installation).

Then, set [Log Integrations](https://docs.datadoghq.com/agent/docker/log/?tab=containerinstallation#log-integrations) as Docker labels:

```yaml
LABEL "com.datadoghq.ad.logs"='[{"source":"nginx","service":"nginx"}]'
```

{% /tab %}

{% tab title="Kubernetes" %}
#### Kubernetes{% #kubernetes %}

To configure this check for an Agent running on Kubernetes:

##### Metric collection{% #metric-collection %}

To collect metrics, set the following parameters and values in an [Autodiscovery template](https://docs.datadoghq.com/agent/kubernetes/integrations/). You can do this with Kubernetes Annotations (shown below) on your NGINX pod(s), or with a [local file, ConfigMap, key-value store, Datadog Operator manifest, or Helm chart](https://docs.datadoghq.com/agent/kubernetes/integrations/?tab=kubernetes#configuration).

| Parameter            | Value                                                          |
| -------------------- | -------------------------------------------------------------- |
| `<INTEGRATION_NAME>` | `["nginx"]`                                                    |
| `<INIT_CONFIG>`      | `[{}]`                                                         |
| `<INSTANCE_CONFIG>`  | `[{"nginx_status_url": "http://%%host%%:18080/nginx_status"}]` |

**Annotations v1** (for Datadog Agent < v7.36)

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  annotations:
    ad.datadoghq.com/nginx.check_names: '["nginx"]'
    ad.datadoghq.com/nginx.init_configs: '[{}]'
    ad.datadoghq.com/nginx.instances: |
      [
        {
          "nginx_status_url":"http://%%host%%:81/nginx_status/"
        }
      ]
  labels:
    name: nginx
```

**Annotations v2** (for Datadog Agent v7.36+)

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  annotations:
    ad.datadoghq.com/nginx.checks: |
      {
        "nginx": {
          "init_config": {},
          "instances": [
            {
              "nginx_status_url":"http://%%host%%:81/nginx_status/"
            }
          ]
        }
      }
  labels:
    name: nginx
```

**Note**: This instance configuration works only with NGINX Open Source. If you are using NGINX Plus, inline the corresponding instance configuration.

#### Log collection{% #log-collection %}

Collecting logs is disabled by default in the Datadog Agent. To enable it, see [Kubernetes Log Collection](https://docs.datadoghq.com/agent/kubernetes/log/?tab=containerinstallation#setup).

Then, set the following parameter in an [Autodiscovery template](https://docs.datadoghq.com/agent/kubernetes/integrations/). You can do this with Kubernetes Annotations (shown below) on your Redis pod(s), or with a [local file, ConfigMap, key-value store, Datadog Operator manifest, or Helm chart](https://docs.datadoghq.com/agent/kubernetes/integrations/?tab=kubernetes#configuration).

| Parameter      | Value                                    |
| -------------- | ---------------------------------------- |
| `<LOG_CONFIG>` | `[{"source":"nginx","service":"nginx"}]` |

**Annotations v1/v2**

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: nginx
  annotations:
    ad.datadoghq.com/nginx.logs: '[{"source":"nginx","service":"nginx"}]'
  labels:
    name: nginx
```

{% /tab %}

{% tab title="ECS" %}
#### ECS{% #ecs %}

To configure this check for an Agent running on ECS:

##### Metric collection{% #metric-collection %}

Set [Autodiscovery Integrations Templates](https://docs.datadoghq.com/agent/docker/integrations/?tab=docker) as Docker labels on your application container:

```json
{
  "containerDefinitions": [{
    "name": "nginx",
    "image": "nginx:latest",
    "dockerLabels": {
      "com.datadoghq.ad.check_names": "[\"nginx\"]",
      "com.datadoghq.ad.init_configs": "[{}]",
      "com.datadoghq.ad.instances": "[{\"nginx_status_url\":\"http://%%host%%:81/nginx_status/\"}]"
    }
  }]
}
```

**Note**: This instance configuration works only with NGINX Open Source. If you are using NGINX Plus, inline the corresponding instance configuration.

##### Log collection{% #log-collection %}

Collecting logs is disabled by default in the Datadog Agent. To enable it, see [ECS Log Collection](https://docs.datadoghq.com/agent/amazon_ecs/logs/?tab=linux).

Then, set [Log Integrations](https://docs.datadoghq.com/agent/docker/log/?tab=containerinstallation#log-integrations) as Docker labels:

```yaml
{
  "containerDefinitions": [{
    "name": "nginx",
    "image": "nginx:latest",
    "dockerLabels": {
      "com.datadoghq.ad.logs": "[{\"source\":\"nginx\",\"service\":\"nginx\"}]"
    }
  }]
}
```

{% /tab %}

### Validation{% #validation %}

[Run the Agent's status subcommand](https://docs.datadoghq.com/agent/guide/agent-commands/#agent-status-and-information) and look for `nginx` under the Checks section.

## Data Collected{% #data-collected %}

### Metrics{% #metrics %}

|  |
|  |
| **nginx.cache.bypass.bytes**(gauge)                                     | The total number of bytes read from the proxied server*Shown as byte*                                                                                                            |
| **nginx.cache.bypass.bytes\_count**(count)                              | The total number of bytes read from the proxied server (shown as count)*Shown as byte*                                                                                           |
| **nginx.cache.bypass.bytes\_written**(gauge)                            | The total number of bytes written to the cache*Shown as byte*                                                                                                                    |
| **nginx.cache.bypass.bytes\_written\_count**(count)                     | The total number of bytes written to the cache (shown as count)*Shown as byte*                                                                                                   |
| **nginx.cache.bypass.responses**(gauge)                                 | The total number of responses not taken from the cache*Shown as response*                                                                                                        |
| **nginx.cache.bypass.responses\_count**(count)                          | The total number of responses not taken from the cache (shown as count)*Shown as response*                                                                                       |
| **nginx.cache.bypass.responses\_written**(gauge)                        | The total number of responses written to the cache*Shown as response*                                                                                                            |
| **nginx.cache.bypass.responses\_written\_count**(count)                 | The total number of responses written to the cache (shown as count)*Shown as response*                                                                                           |
| **nginx.cache.cold**(gauge)                                             | A boolean value indicating whether the cache loader process is still loading data from disk into the cache*Shown as response*                                                    |
| **nginx.cache.expired.bytes**(gauge)                                    | The total number of bytes read from the proxied server*Shown as byte*                                                                                                            |
| **nginx.cache.expired.bytes\_count**(count)                             | The total number of bytes read from the proxied server (shown as count)*Shown as byte*                                                                                           |
| **nginx.cache.expired.bytes\_written**(gauge)                           | The total number of bytes written to the cache*Shown as byte*                                                                                                                    |
| **nginx.cache.expired.bytes\_written\_count**(count)                    | The total number of bytes written to the cache (shown as count)*Shown as byte*                                                                                                   |
| **nginx.cache.expired.responses**(gauge)                                | The total number of responses not taken from the cache*Shown as response*                                                                                                        |
| **nginx.cache.expired.responses\_count**(count)                         | The total number of responses not taken from the cache (shown as count)*Shown as response*                                                                                       |
| **nginx.cache.expired.responses\_written**(gauge)                       | The total number of responses written to the cache*Shown as response*                                                                                                            |
| **nginx.cache.expired.responses\_written\_count**(count)                | The total number of responses written to the cache (shown as count)*Shown as response*                                                                                           |
| **nginx.cache.hit.bytes**(gauge)                                        | The total number of bytes read from the cache*Shown as byte*                                                                                                                     |
| **nginx.cache.hit.bytes\_count**(count)                                 | The total number of bytes read from the cache (shown as count)*Shown as byte*                                                                                                    |
| **nginx.cache.hit.responses**(gauge)                                    | The total number of responses read from the cache*Shown as response*                                                                                                             |
| **nginx.cache.hit.responses\_count**(count)                             | The total number of responses read from the cache (shown as count)*Shown as response*                                                                                            |
| **nginx.cache.max\_size**(gauge)                                        | The limit on the maximum size of the cache specified in the configuration*Shown as byte*                                                                                         |
| **nginx.cache.miss.bytes**(gauge)                                       | The total number of bytes read from the proxied server*Shown as byte*                                                                                                            |
| **nginx.cache.miss.bytes\_count**(count)                                | The total number of bytes read from the proxied server (shown as count)*Shown as byte*                                                                                           |
| **nginx.cache.miss.bytes\_written**(gauge)                              | The total number of bytes written to the cache*Shown as byte*                                                                                                                    |
| **nginx.cache.miss.bytes\_written\_count**(count)                       | The total number of bytes written to the cache (shown as count)*Shown as byte*                                                                                                   |
| **nginx.cache.miss.responses**(gauge)                                   | The total number of responses not taken from the cache*Shown as response*                                                                                                        |
| **nginx.cache.miss.responses\_count**(count)                            | The total number of responses not taken from the cache (shown as count)*Shown as response*                                                                                       |
| **nginx.cache.miss.responses\_written**(gauge)                          | The total number of responses written to the cache*Shown as response*                                                                                                            |
| **nginx.cache.miss.responses\_written\_count**(count)                   | The total number of responses written to the cache*Shown as response*                                                                                                            |
| **nginx.cache.revalidated.bytes**(gauge)                                | The total number of bytes read from the cache*Shown as byte*                                                                                                                     |
| **nginx.cache.revalidated.bytes\_count**(count)                         | The total number of bytes read from the cache (shown as count)*Shown as byte*                                                                                                    |
| **nginx.cache.revalidated.responses**(gauge)                            | The total number of responses read from the cache*Shown as response*                                                                                                             |
| **nginx.cache.revalidated.responses\_count**(count)                     | The total number of responses read from the cache (shown as count)*Shown as response*                                                                                            |
| **nginx.cache.size**(gauge)                                             | The current size of the cache*Shown as response*                                                                                                                                 |
| **nginx.cache.stale.bytes**(gauge)                                      | The total number of bytes read from the cache*Shown as byte*                                                                                                                     |
| **nginx.cache.stale.bytes\_count**(count)                               | The total number of bytes read from the cache (shown as count)*Shown as byte*                                                                                                    |
| **nginx.cache.stale.responses**(gauge)                                  | The total number of responses read from the cache*Shown as response*                                                                                                             |
| **nginx.cache.stale.responses\_count**(count)                           | The total number of responses read from the cache (shown as count)*Shown as response*                                                                                            |
| **nginx.cache.updating.bytes**(gauge)                                   | The total number of bytes read from the cache*Shown as byte*                                                                                                                     |
| **nginx.cache.updating.bytes\_count**(count)                            | The total number of bytes read from the cache (shown as count)*Shown as byte*                                                                                                    |
| **nginx.cache.updating.responses**(gauge)                               | The total number of responses read from the cache*Shown as response*                                                                                                             |
| **nginx.cache.updating.responses\_count**(count)                        | The total number of responses read from the cache (shown as count)*Shown as response*                                                                                            |
| **nginx.connections.accepted**(gauge)                                   | The total number of accepted client connections.*Shown as connection*                                                                                                            |
| **nginx.connections.accepted\_count**(count)                            | The total number of accepted client connections (shown as count).*Shown as connection*                                                                                           |
| **nginx.connections.active**(gauge)                                     | The current number of active client connections.*Shown as connection*                                                                                                            |
| **nginx.connections.dropped**(gauge)                                    | The total number of dropped client connections.*Shown as connection*                                                                                                             |
| **nginx.connections.dropped\_count**(count)                             | The total number of dropped client connections (shown as count).*Shown as connection*                                                                                            |
| **nginx.connections.idle**(gauge)                                       | The current number of idle client connections.*Shown as connection*                                                                                                              |
| **nginx.generation**(gauge)                                             | The total number of configuration reloads*Shown as refresh*                                                                                                                      |
| **nginx.generation\_count**(count)                                      | The total number of configuration reloads (shown as count)*Shown as refresh*                                                                                                     |
| **nginx.limit\_conn.passed**(count)                                     | The total number of connections that were neither limited nor accounted as limited.*Shown as connection*                                                                         |
| **nginx.limit\_conn.rejected**(count)                                   | The total number of connections that were rejected.*Shown as connection*                                                                                                         |
| **nginx.limit\_conn.rejected\_dry\_run**(count)                         | The total number of connections accounted as rejected in the dry run mode.*Shown as connection*                                                                                  |
| **nginx.limit\_req.delayed**(count)                                     | The total number of requests that were delayed.*Shown as request*                                                                                                                |
| **nginx.limit\_req.delayed\_dry\_run**(count)                           | The total number of requests accounted as delayed in the dry run mode.*Shown as request*                                                                                         |
| **nginx.limit\_req.passed**(count)                                      | The total number of requests that were neither limited nor accounted as limited.*Shown as request*                                                                               |
| **nginx.limit\_req.rejected**(count)                                    | The total number of requests that were rejected.*Shown as request*                                                                                                               |
| **nginx.limit\_req.rejected\_dry\_run**(count)                          | The total number of requests accounted as rejected in the dry run mode.*Shown as request*                                                                                        |
| **nginx.load\_timestamp**(gauge)                                        | Time of the last reload of configuration (time since Epoch).*Shown as millisecond*                                                                                               |
| **nginx.location\_zone.discarded**(count)                               | The total number of requests completed without sending a response.*Shown as request*                                                                                             |
| **nginx.location\_zone.received**(count)                                | The total number of bytes received from clients.*Shown as byte*                                                                                                                  |
| **nginx.location\_zone.requests**(count)                                | The total number of client requests received from clients.*Shown as request*                                                                                                     |
| **nginx.location\_zone.responses.1xx**(count)                           | The total number of responses with 1xx status codes.*Shown as response*                                                                                                          |
| **nginx.location\_zone.responses.2xx**(count)                           | The total number of responses with 2xx status codes.*Shown as response*                                                                                                          |
| **nginx.location\_zone.responses.3xx**(count)                           | The total number of responses with 3xx status codes.*Shown as response*                                                                                                          |
| **nginx.location\_zone.responses.4xx**(count)                           | The total number of responses with 4xx status codes.*Shown as response*                                                                                                          |
| **nginx.location\_zone.responses.5xx**(count)                           | The total number of responses with 5xx status codes.*Shown as response*                                                                                                          |
| **nginx.location\_zone.responses.code**(count)                          | The total number of responses per each status code.*Shown as response*                                                                                                           |
| **nginx.location\_zone.responses.total**(count)                         | The total number of responses sent to clients.*Shown as response*                                                                                                                |
| **nginx.location\_zone.sent**(count)                                    | The total number of bytes sent to clients.*Shown as byte*                                                                                                                        |
| **nginx.net.conn\_dropped\_per\_s**(rate)                               | Rate of connections dropped (Included with open source NGINX).*Shown as connection*                                                                                              |
| **nginx.net.conn\_opened\_per\_s**(rate)                                | Rate of connections opened (Included with open source NGINX).*Shown as connection*                                                                                               |
| **nginx.net.connections**(gauge)                                        | The total number of active connections (Included with open source NGINX).*Shown as connection*                                                                                   |
| **nginx.net.reading**(gauge)                                            | The number of connections reading client requests (Included with open source NGINX).*Shown as connection*                                                                        |
| **nginx.net.request\_per\_s**(rate)                                     | Rate of requests processed. Measures both successful and failed requests (Included with open source NGINX).*Shown as request*                                                    |
| **nginx.net.waiting**(gauge)                                            | The number of keep-alive connections waiting for work (Included with open source NGINX).*Shown as connection*                                                                    |
| **nginx.net.writing**(gauge)                                            | The number of connections waiting on upstream responses and/or writing responses back to the client (Included with open source NGINX).*Shown as connection*                      |
| **nginx.pid**(gauge)                                                    | The ID of the worker process that handled status request.                                                                                                                        |
| **nginx.ppid**(gauge)                                                   | The ID of the master process that started the worker process                                                                                                                     |
| **nginx.processes.respawned**(gauge)                                    | The total number of abnormally terminated and respawned child processes.*Shown as process*                                                                                       |
| **nginx.processes.respawned\_count**(count)                             | The total number of abnormally terminated and respawned child processes (shown as count).*Shown as process*                                                                      |
| **nginx.requests.current**(gauge)                                       | The current number of client requests.*Shown as request*                                                                                                                         |
| **nginx.requests.total**(gauge)                                         | The total number of client requests.*Shown as request*                                                                                                                           |
| **nginx.requests.total\_count**(count)                                  | The total number of client requests (shown as count).*Shown as request*                                                                                                          |
| **nginx.resolver.requests.addr**(count)                                 | The total number of requests to resolve addresses to names.*Shown as request*                                                                                                    |
| **nginx.resolver.requests.name**(count)                                 | The total number of requests to resolve names to addresses.*Shown as request*                                                                                                    |
| **nginx.resolver.requests.srv**(count)                                  | The total number of requests to resolve SRV records.*Shown as request*                                                                                                           |
| **nginx.resolver.responses.formerr**(count)                             | The total number of FORMERR (Format error) responses.*Shown as response*                                                                                                         |
| **nginx.resolver.responses.noerror**(count)                             | The total number of successful responses.*Shown as response*                                                                                                                     |
| **nginx.resolver.responses.notimp**(count)                              | The total number of NOTIMP (Unimplemented) responses.*Shown as response*                                                                                                         |
| **nginx.resolver.responses.nxdomain**(count)                            | The total number of NXDOMAIN (Host not found) responses.*Shown as response*                                                                                                      |
| **nginx.resolver.responses.refused**(count)                             | The total number of REFUSED (Operation refused) responses.*Shown as response*                                                                                                    |
| **nginx.resolver.responses.servfail**(count)                            | The total number of SERVFAIL (Server failure) responses.*Shown as response*                                                                                                      |
| **nginx.resolver.responses.timedout**(count)                            | The total number of timed out requests.*Shown as request*                                                                                                                        |
| **nginx.resolver.responses.unknown**(count)                             | The total number of requests completed with an unknown error.*Shown as request*                                                                                                  |
| **nginx.server\_zone.discarded**(gauge)                                 | The total number of requests completed without sending a response.*Shown as request*                                                                                             |
| **nginx.server\_zone.discarded\_count**(count)                          | The total number of requests completed without sending a response (shown as count).*Shown as request*                                                                            |
| **nginx.server\_zone.processing**(gauge)                                | The number of client requests that are currently being processed.*Shown as request*                                                                                              |
| **nginx.server\_zone.received**(gauge)                                  | The total amount of data received from clients.*Shown as byte*                                                                                                                   |
| **nginx.server\_zone.received\_count**(count)                           | The total amount of data received from clients (shown as count).*Shown as byte*                                                                                                  |
| **nginx.server\_zone.requests**(gauge)                                  | The total number of client requests received from clients.*Shown as request*                                                                                                     |
| **nginx.server\_zone.requests\_count**(count)                           | The total number of client requests received from clients (shown as count).*Shown as request*                                                                                    |
| **nginx.server\_zone.responses.1xx**(gauge)                             | The number of responses with 1xx status code.*Shown as response*                                                                                                                 |
| **nginx.server\_zone.responses.1xx\_count**(count)                      | The number of responses with 1xx status code (shown as count).*Shown as response*                                                                                                |
| **nginx.server\_zone.responses.2xx**(gauge)                             | The number of responses with 2xx status code.*Shown as response*                                                                                                                 |
| **nginx.server\_zone.responses.2xx\_count**(count)                      | The number of responses with 2xx status code (shown as count).*Shown as response*                                                                                                |
| **nginx.server\_zone.responses.3xx**(gauge)                             | The number of responses with 3xx status code.*Shown as response*                                                                                                                 |
| **nginx.server\_zone.responses.3xx\_count**(count)                      | The number of responses with 3xx status code (shown as count).*Shown as response*                                                                                                |
| **nginx.server\_zone.responses.4xx**(gauge)                             | The number of responses with 4xx status code.*Shown as response*                                                                                                                 |
| **nginx.server\_zone.responses.4xx\_count**(count)                      | The number of responses with 4xx status code (shown as count).*Shown as response*                                                                                                |
| **nginx.server\_zone.responses.5xx**(gauge)                             | The number of responses with 5xx status code.*Shown as response*                                                                                                                 |
| **nginx.server\_zone.responses.5xx\_count**(count)                      | The number of responses with 5xx status code (shown as count).*Shown as response*                                                                                                |
| **nginx.server\_zone.responses.code**(count)                            | The total number of responses per each status code, tagged with status code number.*Shown as response*                                                                           |
| **nginx.server\_zone.responses.total**(gauge)                           | The total number of responses sent to clients.*Shown as response*                                                                                                                |
| **nginx.server\_zone.responses.total\_count**(count)                    | The total number of responses sent to clients (shown as count).*Shown as response*                                                                                               |
| **nginx.server\_zone.sent**(gauge)                                      | The total amount of data sent to clients.*Shown as byte*                                                                                                                         |
| **nginx.server\_zone.sent\_count**(count)                               | The total amount of data sent to clients (shown as count).*Shown as byte*                                                                                                        |
| **nginx.slab.pages.free**(gauge)                                        | The current number of free memory pages*Shown as page*                                                                                                                           |
| **nginx.slab.pages.used**(gauge)                                        | The current number of used memory pages*Shown as page*                                                                                                                           |
| **nginx.slab.slot.fails**(gauge)                                        | The number of unsuccessful attempts to allocate memory of specified size*Shown as request*                                                                                       |
| **nginx.slab.slot.fails\_count**(count)                                 | The number of unsuccessful attempts to allocate memory of specified size (shown as count)*Shown as request*                                                                      |
| **nginx.slab.slot.free**(gauge)                                         | The current number of free memory slots                                                                                                                                          |
| **nginx.slab.slot.reqs**(gauge)                                         | The total number of attempts to allocate memory of specified size*Shown as request*                                                                                              |
| **nginx.slab.slot.reqs\_count**(count)                                  | The total number of attempts to allocate memory of specified size (shown as count)*Shown as request*                                                                             |
| **nginx.slab.slot.used**(gauge)                                         | The current number of used memory slots                                                                                                                                          |
| **nginx.ssl.handshakes**(gauge)                                         | The total number of successful SSL handshakes.                                                                                                                                   |
| **nginx.ssl.handshakes\_count**(count)                                  | The total number of successful SSL handshakes (shown as count).                                                                                                                  |
| **nginx.ssl.handshakes\_failed**(gauge)                                 | The total number of failed SSL handshakes.                                                                                                                                       |
| **nginx.ssl.handshakes\_failed\_count**(count)                          | The total number of failed SSL handshakes (shown as count).                                                                                                                      |
| **nginx.ssl.session\_reuses**(gauge)                                    | The total number of session reuses during SSL handshake.                                                                                                                         |
| **nginx.ssl.session\_reuses\_count**(count)                             | The total number of session reuses during SSL handshake (shown as count).                                                                                                        |
| **nginx.stream.limit\_conn.passed**(count)                              | The total number of connections that were neither limited nor accounted as limited.*Shown as connection*                                                                         |
| **nginx.stream.limit\_conn.rejected**(count)                            | The total number of connections that were rejected.*Shown as connection*                                                                                                         |
| **nginx.stream.limit\_conn.rejected\_dry\_run**(count)                  | The total number of connections accounted as rejected in the dry run mode.*Shown as connection*                                                                                  |
| **nginx.stream.server\_zone.connections**(gauge)                        | The total number of connections accepted from clients*Shown as connection*                                                                                                       |
| **nginx.stream.server\_zone.connections\_count**(count)                 | The total number of connections accepted from clients (shown as count)*Shown as connection*                                                                                      |
| **nginx.stream.server\_zone.discarded**(gauge)                          | The total number of requests completed without sending a response.*Shown as request*                                                                                             |
| **nginx.stream.server\_zone.discarded\_count**(count)                   | The total number of requests completed without sending a response (shown as count).*Shown as request*                                                                            |
| **nginx.stream.server\_zone.processing**(gauge)                         | The number of client requests that are currently being processed.*Shown as request*                                                                                              |
| **nginx.stream.server\_zone.received**(gauge)                           | The total amount of data received from clients.*Shown as byte*                                                                                                                   |
| **nginx.stream.server\_zone.received\_count**(count)                    | The total amount of data received from clients (shown as count).*Shown as byte*                                                                                                  |
| **nginx.stream.server\_zone.sent**(gauge)                               | The total amount of data sent to clients.*Shown as byte*                                                                                                                         |
| **nginx.stream.server\_zone.sent\_count**(count)                        | The total amount of data sent to clients (shown as count).*Shown as byte*                                                                                                        |
| **nginx.stream.server\_zone.sessions.2xx**(gauge)                       | The number of responses with 2xx status code.*Shown as session*                                                                                                                  |
| **nginx.stream.server\_zone.sessions.2xx\_count**(count)                | The number of responses with 2xx status code (shown as count).*Shown as session*                                                                                                 |
| **nginx.stream.server\_zone.sessions.4xx**(gauge)                       | The number of responses with 4xx status code.*Shown as session*                                                                                                                  |
| **nginx.stream.server\_zone.sessions.4xx\_count**(count)                | The number of responses with 4xx status code (shown as count).*Shown as session*                                                                                                 |
| **nginx.stream.server\_zone.sessions.5xx**(gauge)                       | The number of responses with 5xx status code.*Shown as session*                                                                                                                  |
| **nginx.stream.server\_zone.sessions.5xx\_count**(count)                | The number of responses with 5xx status code (shown as count).*Shown as session*                                                                                                 |
| **nginx.stream.server\_zone.sessions.total**(gauge)                     | The total number of responses sent to clients.*Shown as session*                                                                                                                 |
| **nginx.stream.server\_zone.sessions.total\_count**(count)              | The total number of responses sent to clients (shown as count).*Shown as session*                                                                                                |
| **nginx.stream.upstream.peers.active**(gauge)                           | The current number of connections*Shown as connection*                                                                                                                           |
| **nginx.stream.upstream.peers.backup**(gauge)                           | A boolean value indicating whether the server is a backup server.                                                                                                                |
| **nginx.stream.upstream.peers.connect\_time**(gauge)                    | The average time to connect to this server.*Shown as millisecond*                                                                                                                |
| **nginx.stream.upstream.peers.connections**(gauge)                      | The total number of client connections forwarded to this server.*Shown as connection*                                                                                            |
| **nginx.stream.upstream.peers.connections\_count**(count)               | The total number of client connections forwarded to this server (shown as count).*Shown as connection*                                                                           |
| **nginx.stream.upstream.peers.downstart**(gauge)                        | The time (time since Epoch) when the server became "unavail" or "checking" or "unhealthy"*Shown as millisecond*                                                                  |
| **nginx.stream.upstream.peers.downtime**(gauge)                         | Total time the server was in the "unavail" or "checking" or "unhealthy" states.*Shown as millisecond*                                                                            |
| **nginx.stream.upstream.peers.downtime\_count**(count)                  | Total time the server was in the "unavail" or "checking" or "unhealthy" states.*Shown as millisecond*                                                                            |
| **nginx.stream.upstream.peers.fails**(gauge)                            | The total number of unsuccessful attempts to communicate with the server.*Shown as error*                                                                                        |
| **nginx.stream.upstream.peers.fails\_count**(count)                     | The total number of unsuccessful attempts to communicate with the server (shown as count).*Shown as error*                                                                       |
| **nginx.stream.upstream.peers.first\_byte\_time**(gauge)                | The average time to receive the first byte of data from this server.*Shown as millisecond*                                                                                       |
| **nginx.stream.upstream.peers.health\_checks.checks**(gauge)            | The total number of health check requests made.*Shown as request*                                                                                                                |
| **nginx.stream.upstream.peers.health\_checks.checks\_count**(count)     | The total number of health check requests made (shown as count).*Shown as request*                                                                                               |
| **nginx.stream.upstream.peers.health\_checks.fails**(gauge)             | The number of failed health checks.*Shown as error*                                                                                                                              |
| **nginx.stream.upstream.peers.health\_checks.fails\_count**(count)      | The number of failed health checks (shown as count).*Shown as error*                                                                                                             |
| **nginx.stream.upstream.peers.health\_checks.last\_passed**(gauge)      | Boolean indicating if the last health check request was successful and passed tests.                                                                                             |
| **nginx.stream.upstream.peers.health\_checks.unhealthy**(gauge)         | How many times the server became unhealthy (state "unhealthy").                                                                                                                  |
| **nginx.stream.upstream.peers.health\_checks.unhealthy\_count**(count)  | How many times the server became unhealthy (state "unhealthy") (shown as count).                                                                                                 |
| **nginx.stream.upstream.peers.id**(gauge)                               | The ID of the server.                                                                                                                                                            |
| **nginx.stream.upstream.peers.max\_conns**(gauge)                       | The max_conns limit for the server.*Shown as connection*                                                                                                                         |
| **nginx.stream.upstream.peers.received**(gauge)                         | The total number of bytes received from this server.*Shown as byte*                                                                                                              |
| **nginx.stream.upstream.peers.received\_count**(count)                  | The total number of bytes received from this server (shown as count).*Shown as byte*                                                                                             |
| **nginx.stream.upstream.peers.response\_time**(gauge)                   | The average time to receive the last byte of data from this server.*Shown as millisecond*                                                                                        |
| **nginx.stream.upstream.peers.response\_time\_histogram**(gauge)        | The average time to receive the last byte of data from this server as a histogram.*Shown as millisecond*                                                                         |
| **nginx.stream.upstream.peers.response\_time\_histogram.avg**(gauge)    | *Shown as millisecond*                                                                                                                                                           |
| **nginx.stream.upstream.peers.response\_time\_histogram.count**(rate)   | *Shown as millisecond*                                                                                                                                                           |
| **nginx.stream.upstream.peers.response\_time\_histogram.max**(gauge)    | *Shown as millisecond*                                                                                                                                                           |
| **nginx.stream.upstream.peers.response\_time\_histogram.median**(gauge) | *Shown as millisecond*                                                                                                                                                           |
| **nginx.stream.upstream.peers.selected**(gauge)                         | The time (time since Epoch) when the server was last selected to process a connection.*Shown as millisecond*                                                                     |
| **nginx.stream.upstream.peers.sent**(gauge)                             | The total number of bytes sent to this server.*Shown as byte*                                                                                                                    |
| **nginx.stream.upstream.peers.sent\_count**(count)                      | The total number of bytes sent to this server (shown as count).*Shown as byte*                                                                                                   |
| **nginx.stream.upstream.peers.unavail**(gauge)                          | How many times the server became unavailable for client connections (state "unavail").                                                                                           |
| **nginx.stream.upstream.peers.unavail\_count**(count)                   | How many times the server became unavailable for client connections (state "unavail") (shown as count).                                                                          |
| **nginx.stream.upstream.peers.weight**(gauge)                           | Weight of the server.                                                                                                                                                            |
| **nginx.stream.upstream.zombies**(gauge)                                | The current number of servers removed from the group but still processing active client connections.*Shown as host*                                                              |
| **nginx.stream.zone\_sync.status.bytes\_in**(gauge)                     | The number of bytes received by this node.*Shown as byte*                                                                                                                        |
| **nginx.stream.zone\_sync.status.bytes\_out**(gauge)                    | The number of bytes sent by this node.*Shown as byte*                                                                                                                            |
| **nginx.stream.zone\_sync.status.msgs\_in**(gauge)                      | The number of messages received by this node.*Shown as message*                                                                                                                  |
| **nginx.stream.zone\_sync.status.msgs\_out**(gauge)                     | The number of messages sent by this node.*Shown as message*                                                                                                                      |
| **nginx.stream.zone\_sync.status.nodes\_online**(gauge)                 | The number of peers this node is connected to.                                                                                                                                   |
| **nginx.stream.zone\_sync.zone.records\_pending**(gauge)                | The number of records that need to be sent to the cluster.*Shown as record*                                                                                                      |
| **nginx.stream.zone\_sync.zone.records\_total**(gauge)                  | The number of records stored in the shared memory zone.*Shown as record*                                                                                                         |
| **nginx.stream.zone\_sync.zone.records\_total\_count**(count)           | The total number of records stored in the shared memory zone.*Shown as record*                                                                                                   |
| **nginx.timestamp**(gauge)                                              | Current time since Epoch.*Shown as millisecond*                                                                                                                                  |
| **nginx.upstream.keepalive**(gauge)                                     | The current number of idle keepalive connections.*Shown as connection*                                                                                                           |
| **nginx.upstream.peers.active**(gauge)                                  | The current number of active connections.*Shown as connection*                                                                                                                   |
| **nginx.upstream.peers.backup**(gauge)                                  | A boolean value indicating whether the server is a backup server.                                                                                                                |
| **nginx.upstream.peers.downstart**(gauge)                               | The time (since Epoch) when the server became "unavail" or "unhealthy".*Shown as millisecond*                                                                                    |
| **nginx.upstream.peers.downtime**(gauge)                                | Total time the server was in the "unavail" and "unhealthy" states.*Shown as millisecond*                                                                                         |
| **nginx.upstream.peers.downtime\_count**(count)                         | Total time the server was in the "unavail" and "unhealthy" states.*Shown as millisecond*                                                                                         |
| **nginx.upstream.peers.fails**(gauge)                                   | The total number of unsuccessful attempts to communicate with the server.                                                                                                        |
| **nginx.upstream.peers.fails\_count**(count)                            | The total number of unsuccessful attempts to communicate with the server (shown as count).                                                                                       |
| **nginx.upstream.peers.header\_time**(gauge)                            | The total amount of time spent on receiving the response header from the upstream server.*Shown as millisecond*                                                                  |
| **nginx.upstream.peers.health\_checks.checks**(gauge)                   | The total number of health check requests made.                                                                                                                                  |
| **nginx.upstream.peers.health\_checks.checks\_count**(count)            | The total number of health check requests made (shown as count).                                                                                                                 |
| **nginx.upstream.peers.health\_checks.fails**(gauge)                    | The number of failed health checks.                                                                                                                                              |
| **nginx.upstream.peers.health\_checks.fails\_count**(count)             | The number of failed health checks (shown as count).                                                                                                                             |
| **nginx.upstream.peers.health\_checks.last\_passed**(gauge)             | Boolean indicating if the last health check request was successful and passed tests.                                                                                             |
| **nginx.upstream.peers.health\_checks.unhealthy**(gauge)                | How many times the server became unhealthy (state "unhealthy").                                                                                                                  |
| **nginx.upstream.peers.health\_checks.unhealthy\_count**(count)         | How many times the server became unhealthy (state "unhealthy") (shown as count).                                                                                                 |
| **nginx.upstream.peers.id**(gauge)                                      | The ID of the server.                                                                                                                                                            |
| **nginx.upstream.peers.max\_conns**(gauge)                              | The max_conns limit for this server.*Shown as connection*                                                                                                                        |
| **nginx.upstream.peers.received**(gauge)                                | The total amount of data received from this server.*Shown as byte*                                                                                                               |
| **nginx.upstream.peers.received\_count**(count)                         | The total amount of data received from this server (shown as count).*Shown as byte*                                                                                              |
| **nginx.upstream.peers.requests**(gauge)                                | The total number of client requests forwarded to this server.*Shown as request*                                                                                                  |
| **nginx.upstream.peers.requests\_count**(count)                         | The total number of client requests forwarded to this server (shown as count).*Shown as request*                                                                                 |
| **nginx.upstream.peers.response\_time**(gauge)                          | The average time to receive the last byte of data from this server.*Shown as millisecond*                                                                                        |
| **nginx.upstream.peers.response\_time\_histogram**(gauge)               | The average time to receive the last byte of data from this server as a histogram.*Shown as millisecond*                                                                         |
| **nginx.upstream.peers.response\_time\_histogram.avg**(gauge)           | *Shown as millisecond*                                                                                                                                                           |
| **nginx.upstream.peers.response\_time\_histogram.count**(rate)          | *Shown as millisecond*                                                                                                                                                           |
| **nginx.upstream.peers.response\_time\_histogram.max**(gauge)           | *Shown as millisecond*                                                                                                                                                           |
| **nginx.upstream.peers.response\_time\_histogram.median**(gauge)        | *Shown as millisecond*                                                                                                                                                           |
| **nginx.upstream.peers.responses.1xx**(gauge)                           | The number of responses with 1xx status code from this server.*Shown as response*                                                                                                |
| **nginx.upstream.peers.responses.1xx\_count**(count)                    | The number of responses with 1xx status code (shown as count) from this server.*Shown as response*                                                                               |
| **nginx.upstream.peers.responses.2xx**(gauge)                           | The number of responses with 2xx status code from this server.*Shown as response*                                                                                                |
| **nginx.upstream.peers.responses.2xx\_count**(count)                    | The number of responses with 2xx status code (shown as count) from this server.*Shown as response*                                                                               |
| **nginx.upstream.peers.responses.3xx**(gauge)                           | The number of responses with 3xx status code from this server.*Shown as response*                                                                                                |
| **nginx.upstream.peers.responses.3xx\_count**(count)                    | The number of responses with 3xx status code (shown as count) from this server.*Shown as response*                                                                               |
| **nginx.upstream.peers.responses.4xx**(gauge)                           | The number of responses with 4xx status code from this server.*Shown as response*                                                                                                |
| **nginx.upstream.peers.responses.4xx\_count**(count)                    | The number of responses with 4xx status code (shown as count) from this server.*Shown as response*                                                                               |
| **nginx.upstream.peers.responses.5xx**(gauge)                           | The number of responses with 5xx status code from this server.*Shown as response*                                                                                                |
| **nginx.upstream.peers.responses.5xx\_count**(count)                    | The number of responses with 5xx status code (shown as count).*Shown as response*                                                                                                |
| **nginx.upstream.peers.responses.code**(count)                          | The total number of responses from this server per each status code.*Shown as response*                                                                                          |
| **nginx.upstream.peers.responses.total**(gauge)                         | The total number of responses obtained from this server.*Shown as response*                                                                                                      |
| **nginx.upstream.peers.responses.total\_count**(count)                  | The total number of responses obtained from this server (shown as count).*Shown as response*                                                                                     |
| **nginx.upstream.peers.selected**(gauge)                                | The time (since Epoch) when the server was last selected to process a request (1.7.5).*Shown as millisecond*                                                                     |
| **nginx.upstream.peers.sent**(gauge)                                    | The total amount of data sent to this server.*Shown as byte*                                                                                                                     |
| **nginx.upstream.peers.sent\_count**(count)                             | The total amount of data sent to this server (shown as count).*Shown as byte*                                                                                                    |
| **nginx.upstream.peers.unavail**(gauge)                                 | How many times the server became unavailable for client requests (state "unavail") due to the number of unsuccessful attempts reaching the max_fails threshold.                  |
| **nginx.upstream.peers.unavail\_count**(count)                          | How many times the server became unavailable for client requests (state "unavail") due to the number of unsuccessful attempts reaching the max_fails threshold (shown as count). |
| **nginx.upstream.peers.weight**(gauge)                                  | Weight of the server.                                                                                                                                                            |
| **nginx.upstream.zombies**(gauge)                                       | The current number of servers removed from the group but still processing active client connections.*Shown as host*                                                              |
| **nginx.version**(gauge)                                                | Version of nginx.                                                                                                                                                                |

### Events{% #events %}

The NGINX check does not include any events.

### Service Checks{% #service-checks %}

**nginx.can\_connect**

Returns `CRITICAL` if the Agent is unable to connect to and collect metrics from the monitored Nginx instance. Returns `OK` otherwise.

*Statuses: ok, critical*

## Troubleshooting{% #troubleshooting %}

- [Why do my logs not have the expected timestamp?](https://docs.datadoghq.com/logs/faq/why-do-my-logs-not-have-the-expected-timestamp/)

Need help? Contact [Datadog support](https://docs.datadoghq.com/help/).

## Further Reading{% #further-reading %}

- [How to monitor NGINX](https://www.datadoghq.com/blog/how-to-monitor-nginx)
- [NGINX Metrics: How to Monitor and Collect](https://www.datadoghq.com/blog/how-to-collect-nginx-metrics/index.html)
- [How to monitor NGINX with Datadog](https://www.datadoghq.com/blog/how-to-monitor-nginx-with-datadog/index.html)
