Custom Metrics Configuration#
Angie can collect custom numeric metrics in shared memory and expose them via
the real-time statistics API at
/status/http/metric_zones/. This is provided by the
Metric module.
Note
This guide covers metrics for HTTP traffic. For TCP and UDP traffic, see
the Stream Metric module, which exposes its zones
at /status/stream/metric_zones/.
Configuration Steps#
Define a metric zone in the
httpblock:metric_zone creates a zone with a single metric mode.
metric_complex_zone creates a zone with multiple named metrics.
Update metrics in request processing with the metric directive. Use a
key=valuepair (both are complex values), and choose the update stage withon=(request,response, orend).Expose the API with a
location:location /status/ { api /status/http/metric_zones/; }
Example#
Count requests per host and expose the metrics in the API:
http {
metric_zone requests:128k count;
server {
listen 80;
location / {
metric requests $host=1;
}
location /status/ {
api /status/http/metric_zones/;
}
}
}
Notes#
If
expire=onis set on the zone and the shared memory is full, the least recently used entries are expired. Ifexpire=off, new updates are discarded and thediscardedcounter grows.If
discard_keyis set, metrics from expired entries are aggregated under that key in the API output.Keys and values are limited to 255 bytes; longer keys are truncated in the API.
An empty value is treated as
0, and a non-empty value without a leading number is treated as1.