Enable metrics
The NGINX One Console dashboard relies on APIs for NGINX Plus and NGINX Open Source Stub Status to report traffic and system metrics. The following sections show you how to enable those metrics.
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:
# This block enables the NGINX Plus API and dashboard
# 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;
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 and set your network:
# allow 192.0.2.0/24 # replace with your network
# deny all;
}
# Serve the built-in dashboard at /dashboard.html
location = /dashboard.html {
root /usr/share/nginx/html;
}
}
Security tip
- By default, all clients can call the API.
- To limit who can access the API, uncomment the
allow
anddeny
lines underapi write=on
and replace the example CIDR with your trusted network.- To restrict write methods (
POST
,PATCH
,DELETE
), uncomment and configure thelimit_except GET
block and set up HTTP basic authentication.
For more details, see the NGINX Plus API module documentation and Configuring the NGINX Plus API.
To enable the NGINX Plus API and dashboard with Config Sync Groups, add a file named /etc/nginx/conf.d/dashboard.conf
to your shared group config. Any instance you add to that group automatically uses those settings.
- In the NGINX One Console, select Manage > Config Sync Groups, then pick your config sync group’s name.
- Select the Configuration tab, then select Edit Configuration.
- Select Add File.
- Select New Configuration File.
- In the File name box, enter
/etc/nginx/conf.d/dashboard.conf
, then select Add. - Paste the following into the new file workspace:
# This block enables the NGINX Plus API and dashboard
# 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;
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 and set your network:
# allow 192.0.2.0/24 # replace with your network
# deny all;
}
# Serve the built-in dashboard at /dashboard.html
location = /dashboard.html {
root /usr/share/nginx/html;
}
}
- Select Next, review the diff, then select Save and Publish.
To collect basic metrics about server activity for NGINX Open Source, add the following to your NGINX configuration file:
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.
After saving the changes, reload NGINX to apply the new configuration:
nginx -s reload