http-statsd #
Emits per-request StatsD metrics (counts, timings) from inside nginx — good for dashboards when full Prometheus instrumentation is overkill.
Source: upstream source
Directives
statsd_count #
syntax: statsd_count 2 args; · context: server, location, server-if, location-if
Only sends the value if # the custom header exists in the upstream response. statsd_count "your_product.custom_$upstream_http_x_some_custom_header" 1 "$upstream_http_x_some_custom_header"; proxy_pass http://some.other.domain.com; } } }
statsd_sample_rate #
syntax: statsd_sample_rate 1 arg (integer); · context: http, server, location
Integer value.
statsd_server #
syntax: statsd_server 1 arg; · context: http, server, location
Sets the address of the statsd server to which nginx sends collected statistics.
statsd_timing #
syntax: statsd_timing 2 args; · context: server, location, server-if, location-if
Thus, there is no need to add a test. statsd_timing "your_product.pages.index_response_time" "$upstream_response_time"; # Increment a key based on the value of a custom header.
Example
http {
statsd_server 127.0.0.1:8125;
statsd_sample_rate 100;
server {
location / {
statsd_count "nginx.requests.${status}" 1;
statsd_timing "nginx.request_time" $request_time;
proxy_pass http://backend;
}
}
}