Skip to content
Closed
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
31 changes: 31 additions & 0 deletions content/nginx-one/nginx-configs/metrics/enable-metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,34 @@ The NGINX One Console dashboard relies on APIs for NGINX Plus and NGINX Open Sou
### Enable NGINX Open Source Stub Status API

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

### Include response codes

To collect response codes in your log files, set a `status_zone` in descired `location` blocks. Here's an
example that you could add to your NGINX configuration file:

```nginx
server {
listen 8080;

# - add response header
add_header "x-datapath-instance" "<datapath_id>" always;

default_type text/plain;

location / {
status_zone systest_loc_200;
return 200 "hello from datapath <datapath_id>\n";
}

location /4xx {
status_zone systest_loc_4xx;
return 400 "fake 400 from datapath <datapath_id>\n";
}

location /5xx {
status_zone systest_loc_5xx;
return 500 "fake 500 from datapath <datapath_id>\n";
}
}
```