Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ server {
}
}
```

{{<call-out type="important" title="Important">}}
Make sure that the `server` and `location` blocks are in the same single configuration file, and not split across multiple files using `include` directives.
{{</call-out>}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
nd-product: MSC
nd-files:
- content/nginx-one-console/getting-started.md
- content/nginx-one-console/nginx-configs/metrics/enable-metrics.md
- content/nim/monitoring/overview-metrics.md
- content/nim/nginx-instances/add-instance.md
---

To collect basic metrics about server activity for NGINX Open Source:

1. **Enable the stub status API**

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;
}
}
```

{{<call-out type="important" title="Important">}}
Make sure that the `server` and `location` blocks are in the same single configuration file, and not split across multiple files using `include` directives.
{{</call-out>}}

This configuration:

- Enables the stub status API endpoint
- 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).

2. **Configure access logging**

Enable access logging in your NGINX configuration to collect detailed traffic metrics. Ensure that the following log format is used:

```nginx
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$bytes_sent" "$request_length" "$request_time" '
'"$gzip_ratio" $server_protocol ';
access_log /var/log/nginx/access.log main;
```

This log format captures key metrics including request timing, response sizes and client information.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
nd-product: MSC
nd-files:
- content/nginx-one-console/getting-started.md
---

If SSL is enabled on the NGINX Plus API with self-signed certificates like this example:

```nginx
# This block enables the NGINX Plus API and dashboard with SSL
# For configuration and security recommendations, see:
# https://docs.nginx.com/nginx/admin-guide/monitoring/live-activity-monitoring/#configuring-the-api
server {
# Change the listen port if 9000 conflicts
# (8080 is the conventional API port)
listen 9000 ssl;
ssl_certificate /etc/nginx/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/nginx/certs/nginx-selfsigned.key;
location /api/ {
# To restrict write methods (POST, PATCH, DELETE), uncomment:
# limit_except GET {
# auth_basic "NGINX Plus API";
# auth_basic_user_file /path/to/passwd/file;
# }
# Enable API in write mode
api write=on;
# To restrict access by network, uncomment the following lines and set your network:
# allow 192.0.2.0/24; # replace with your network
# allow 127.0.0.1/32; # allow local NGINX Agent to call the NGINX Plus API to retrieve metrics
# deny all;
}
# Serve the built-in dashboard at /dashboard.html
location = /dashboard.html {
root /usr/share/nginx/html;
}
}
```

{{<call-out type="important" title="Important">}}
Make sure that the `server` and `location` blocks are in the same single configuration file, and not split across multiple files using `include` directives.
{{</call-out>}}

NGINX Agent configuration needs to be update with the following to enable the NGINX Agent to be able to call the NGINX Plus API.
```
data_plane_config:
nginx:
api_tls:
ca: "/etc/nginx/certs/nginx-selfsigned.crt"
```

Here is an example of how to generate self-signed certificates
```
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/certs/nginx-selfsigned.key -out /etc/nginx/certs/nginx-selfsigned.crt -subj "/CN=localhost" -addext "subjectAltName=IP:127.0.0.1"
```
22 changes: 13 additions & 9 deletions content/nginx-one-console/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,22 @@ The NGINX One Console dashboard relies on APIs for NGINX Plus and NGINX Open Sou

### Enable NGINX Plus API

{{<tabs name="enable-nginx-metrics" >}}

{{%tab name="without SSL"%}}
{{< include "/use-cases/monitoring/enable-nginx-plus-api.md" >}}

### Enable NGINX Open Source Stub Status API
{{% /tab %}}
{{%tab name="with SSL"%}}

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

{{% /tab %}}
{{% /tabs %}}

{{< include "/use-cases/monitoring/enable-nginx-oss-stub-status.md" >}}
### Enable NGINX Open Source Metric

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

---

Expand All @@ -181,10 +192,3 @@ After connecting your NGINX instances to NGINX One, you can monitor their perfor
### Overview of the NGINX One dashboard

{{< include "/use-cases/monitoring/n1c-dashboard-overview.md" >}}







Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ nd-product: NONECO
The NGINX One Console dashboard and metrics views present system metrics and detailed NGINX metrics gathered through the NGINX Plus API or the Stub Status API (for NGINX Open Source).

To display metrics, complete the following steps:

1. Enable the API
2. Enable metric collection

Expand All @@ -28,9 +29,9 @@ To enable the NGINX Plus API and dashboard with [Config Sync Groups]({{< ref "/n

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

## Enable NGINX Open Source Stub Status API
## Enable NGINX Open Source Metrics

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

## Enable NGINX Plus Metric Collection

Expand Down
16 changes: 1 addition & 15 deletions content/nim/monitoring/overview-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,28 +36,14 @@ NGINX Instance Manager stores historical data in an analytics database and appli

### NGINX Open Source metrics

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

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

```shell
nginx -s reload
```

### NGINX access log metrics

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" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$bytes_sent" "$request_length" "$request_time" '
'"$gzip_ratio" $server_protocol ';

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

## Troubleshooting

System metrics are collected automatically by the NGINX Agent. To collect NGINX-specific metrics, additional configuration is required.
4 changes: 2 additions & 2 deletions content/nim/nginx-instances/add-instance.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Make sure you have:

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

### Enable NGINX Open Source Stub Status API
### Enable NGINX Open Source Metrics

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

## Next steps

Expand Down