diff --git a/content/nginx-one/nginx-configs/metrics/enable-metrics.md b/content/nginx-one/nginx-configs/metrics/enable-metrics.md index 0e677a78c..fd4419014 100644 --- a/content/nginx-one/nginx-configs/metrics/enable-metrics.md +++ b/content/nginx-one/nginx-configs/metrics/enable-metrics.md @@ -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" "" always; + + default_type text/plain; + + location / { + status_zone systest_loc_200; + return 200 "hello from datapath \n"; + } + + location /4xx { + status_zone systest_loc_4xx; + return 400 "fake 400 from datapath \n"; + } + + location /5xx { + status_zone systest_loc_5xx; + return 500 "fake 500 from datapath \n"; + } +} +```