Skip to content

Add steps to enable NGINX Plus API and NGINX OSS stub_status for metrics reporting #227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
docs:
files:
- content/nim/monitoring/overview-metrics.md
- content/nginx-one/getting-started.md
---

To collect basic metrics about server activity for NGINX Open Source, add the following to your NGINX configuration file:

```nginx
server {
listen 127.0.0.1:8080;
location /api {
stub_status;
allow 127.0.0.1;
deny all;
}
}
```

This configuration:

- Enables the stub status API.
- Allows requests only from `127.0.0.1` (localhost).
- Blocks all other requests for security.

For more details, see the [NGINX Stub Status module documentation](https://nginx.org/en/docs/http/ngx_http_stub_status_module.html).

After saving the changes, reload NGINX to apply the new configuration:

```shell
nginx -s reload
```
33 changes: 33 additions & 0 deletions content/includes/use-cases/monitoring/enable-nginx-plus-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
docs:
files:
- content/nim/monitoring/overview-metrics.md
- content/nginx-one/getting-started.md
---

To collect comprehensive metrics for NGINX Plus--including bytes streamed, information about upstream systems and caches, and counts of all HTTP status codes--add the following to your NGINX Plus configuration file (for example, `/etc/nginx/nginx.conf` or an included file):

```nginx
# Enable the /api/ location with appropriate access control
# to use the NGINX Plus API.
#
location /api/ {
api write=on;
allow 127.0.0.1;
deny all;
}
```

This configuration:

- Enables the NGINX Plus API.
- Allows requests only from `127.0.0.1` (localhost).
- Blocks all other requests for security.

For more details, see the [NGINX Plus API module documentation](https://nginx.org/en/docs/http/ngx_http_api_module.html).

After saving the changes, reload NGINX to apply the new configuration:

```shell
nginx -s reload
```
18 changes: 18 additions & 0 deletions content/nginx-one/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ To get started using NGINX One, enable the service on F5 Distributed Cloud.
1. Select **Enable Service**.
1. After the service has been enabled, select **Visit Service** to load the NGINX One console.

---

## Add your NGINX instances to NGINX One

Next, add your NGINX instances to NGINX One. You'll need to create a data plane key and then install the NGINX Agent on each instance you want to monitor.
Expand Down Expand Up @@ -130,6 +132,22 @@ If you followed the [Installation and upgrade](https://docs.nginx.com/nginx-agen

</span>

---

## Enable NGINX metrics reporting

In order for the NGINX One console to show specific traffic and system metrics, you need to enable the appropriate API on your NGINX data plane instances. The sections below provide step-by-step instructions for both NGINX Plus and NGINX Open Source (OSS).

### Enable NGINX Plus API

{{< include "/use-cases/monitoring/enable-nginx-plus-api.md" >}}

### Enable NGINX Open Source Stub Status API

{{< include "/use-cases/monitoring/enable-nginx-oss-stub-status.md" >}}

---

## View instance metrics with the NGINX One dashboard

After connecting your NGINX instances to NGINX One, you can monitor their performance and health. The NGINX One dashboard is designed for this purpose, offering an easy-to-use interface.
Expand Down
60 changes: 19 additions & 41 deletions content/nim/monitoring/overview-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,37 @@ weight: 100

## Overview

The data that NGINX Instance Manager collects can be divided into two categories:
F5 NGINX Instance Manager collects two types of data:

- **System metrics**: Data collected about the data plane system, such as CPU and memory usage.
- **Traffic metrics**: Data related to processed traffic from sources such as NGINX OSS, NGINX Plus, or NGINX logs.
- **System metrics**: Data about the data plane system, such as CPU and memory usage.
- **Traffic metrics**: Data from processed traffic, including NGINX OSS, NGINX Plus, and NGINX logs.

Metrics are collected every 15 seconds and are published at 60-second intervals.
The NGINX Agent collects metrics every 15 seconds and publishes them every 60 seconds.

For the full list of metrics, see the [Metrics Catalog Reference]({{< relref "/nms/reference/catalogs//metrics.md" >}})
For a full list of available metrics, see the [Metrics Catalog Reference]({{< relref "/nms/reference/catalogs//metrics.md" >}}).

## Metrics Collection and Reporting Process
## How metrics are collected and reported

While the NGINX Agent is running on the host, it collects metrics at regular 15-second intervals. Metrics then are downsampled and sent to the Manager server once per minute.
The NGINX Agent collects metrics every 15 seconds while running on the host. Metrics are then downsampled and sent to the Manager server once per minute.

NGINX Instance Manager stores historical metrics data in an analytics database. Metrics are aggregated and rolled-up as follows:
NGINX Instance Manager stores historical data in an analytics database and applies roll-ups:

- Data not older than 8 days are stored with best possible resolution (usually 1 min).
- Data older than 8 days but not older than 30 days are stored with 5 min resolution.
- Data older than 30 days but not older than 15 months are stored with 1 hour resolution.
- Data older than 15 months are stored with 1 day resolution.
- Data up to **8 days old** is stored with **1-minute resolution**.
- Data **8 to 30 days old** is stored with **5-minute resolution**.
- Data **30 days to 15 months old** is stored with **1-hour resolution**.
- Data older than **15 months** is stored with **1-day resolution**.

### F5 NGINX Plus Metrics
### F5 NGINX Plus metrics

Enable the NGINX Plus API to collect NGINX Plus metrics by uncommenting the `/api/` location section in `/etc/nginx/conf.d/default.conf`:
{{< include "/use-cases/monitoring/enable-nginx-plus-api.md" >}}

```nginx {hl_lines=[4]}
# enable /api/ location with appropriate access control in order
# to make use of NGINX Plus API
#
location /api/ {
api write=on;
allow 127.0.0.1;
deny all;
}
```

### NGINX OSS Metrics

Enable NGINX Stub Status API to collect NGINX metrics in NGINX OSS. A sample Stub Status API configuration is shown below:
### NGINX Open Source metrics

```nginx
server {
listen 127.0.0.1:8080;
location /api {
stub_status;
allow 127.0.0.1;
deny all;
}
}
```
{{< include "/use-cases/monitoring/enable-nginx-oss-stub-status.md" >}}

### NGINX Access Log Metrics
### NGINX access log metrics

Enable NGINX Access Logging to collect metrics from parsing access logs. A sample Access Log format is shown below:
Enable access logging to collect traffic metrics by parsing logs. Use the following log format:

```nginx
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
Expand All @@ -78,4 +56,4 @@ access_log /var/log/nginx/access.log main;

## Troubleshooting

System metrics are collected by the NGINX Agent without requiring the user to perform any additional setup. Additional setup is required to enable collection of NGINX related metrics.
System metrics are collected automatically by the NGINX Agent. To collect NGINX-specific metrics, additional configuration is required.