> [!CAUTION]
> **Caution:** As of September 28, 2026, the legacy Monitoring agent has reached its end of support. Standard maintenance and bug fixes are no longer provided. We strongly recommend migrating to one of the [supported alternatives](https://docs.cloud.google.com/monitoring/agent.md.txt). For more information about this deprecation, see [Legacy
> Monitoring and Logging agents end of support](https://docs.cloud.google.com/stackdriver/docs/deprecations/legacy-agents).

Nginx is a free, open-source, high-performance HTTP server and reverse proxy,
as well as an IMAP/POP3 proxy server.
For more information visit [nginx.org](http://nginx.org/).

This functionality is only available for agents running on Linux. It is
not available on Windows.

> [!NOTE]
> **Note:** You can now collect metrics from your Nginx instance using the [Ops Agent](https://docs.cloud.google.com/stackdriver/docs/solutions/agents/ops-agent.md.txt), the primary and preferred agent for collecting telemetry from your Compute Engine instances. For details, see [configuring the Ops Agent for
> nginx](https://docs.cloud.google.com/stackdriver/docs/solutions/agents/ops-agent/third-party/nginx).

## Discovery

Even if the Nginx plugin is not configured, Cloud Monitoring will discover
Nginx services running in your Cloud Platform project by:

- Searching instance names for **nginx**
- Checking for ports opened to **80** or **443** via firewall rules

To see the metrics for Nginx, do the following:

1. In the Google Cloud console, go to the **Dashboards** page:

   [Go to **Dashboards**](https://console.cloud.google.com/monitoring/dashboards)

   <br />

   If you use the search bar to find this page, then select the result whose subheading is
   **Monitoring**.
2. Select the **Nginx** dashboard from the list.

## Configuring Monitoring to monitor Nginx

After you [install the monitoring agent](https://docs.cloud.google.com/monitoring/agent/monitoring/installation.md.txt), use
the following instructions to configure the Nginx plugin on your instances.

### Prerequisites

The Nginx plugin requires that you enable the status information handler in
Nginx. This can be done by downloading [status.conf](https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/nginx/conf.d/status.conf)
from the [GitHub configuration repository](https://github.com/Stackdriver/stackdriver-agent-service-configs)
and placing it in the Nginx configuration directory (normally `/etc/nginx/conf.d/`):

    (cd /etc/nginx/conf.d/ && sudo curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/nginx/conf.d/status.conf)

Alternatively, you can append the contents of
[status.conf](https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/nginx/conf.d/status.conf)
to your `nginx.conf` file, normally located in one of the following directories
on your VM instance:
`/etc/nginx`, `/usr/local/nginx/conf`, or `/usr/local/etc/nginx`.

> [!CAUTION]
> **Caution:** You should only expose the agent's endpoint to `localhost` through HTTP.

Reload the Nginx configuration by running:

    sudo service nginx reload

### Enabling the Nginx monitoring plugin

On your VM instance, download [nginx.conf](https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/nginx.conf)
from the [GitHub configuration repository](https://github.com/Stackdriver/stackdriver-agent-service-configs)
and place it in the directory `/etc/stackdriver/collectd.d/`:

    (cd /etc/stackdriver/collectd.d/ && sudo curl -O https://raw.githubusercontent.com/Stackdriver/stackdriver-agent-service-configs/master/etc/collectd.d/nginx.conf)

After adding the configuration file, restart the monitoring agent by running the following command:

    sudo service stackdriver-agent restart

For more information on the `collectd` `nginx` plugin, see
[Plugin:nginx](https://collectd.org/wiki/index.php/Plugin:nginx).

## What is monitored

The full list of metrics the Nginx plugin monitors is at
[Agent metrics: nginx](https://docs.cloud.google.com/monitoring/api/metrics_agent.md.txt#agent-nginx).