Custom Metrics Configuration#
Angie can collect custom numeric metrics in shared memory and expose them via
the real-time statistics API at
Define a metric zone in the 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 Expose the API with a Count requests per host and expose the metrics in the API: If If Keys and values are limited to 255 bytes; longer keys are truncated in the API. An empty value is treated as /status/http/metric_zones/. This is provided by the
Metric module.Configuration Steps#
http block:key=value pair (both are complex values), and
choose the update stage with on= (request, response,
or end).location:location /status/ {
api /status/http/metric_zones/;
}
Example#
http {
metric_zone requests:128k count;
server {
listen 80;
location / {
metric requests $host=1;
}
location /status/ {
api /status/http/metric_zones/;
}
}
}
Notes#
expire=on is set on the zone and the shared memory is full, the
least recently used entries are expired. If expire=off, new updates
are discarded and the discarded counter grows.discard_key is set, metrics from expired entries are aggregated
under that key in the API output.0, and a non-empty value without a
leading number is treated as 1.