Prometheus#
Collects Angie statistics, based on templates defined in the configuration, and returns metrics generated from these templates in the Prometheus format.
Attention
To collect statistics, enable a shared memory zone in the appropriate contexts using:
the
zone
directive in http_upstream or stream_upstream;the status_zone directive;
the
status_zone
parameter in the resolver directive.
Configuration Example#
Three metrics for collecting request statistics for server shared memory zones,
combined into the custom
template and published at the /p8s
path:
http {
prometheus_template custom {
'angie_http_server_zones_requests_total{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/total$
type=counter;
'angie_http_server_zones_requests_processing{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/processing$
type=gauge;
'angie_http_server_zones_requests_discarded{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/discarded$
type=counter;
}
# ...
server {
listen 80;
location =/p8s {
prometheus custom;
}
# ...
}
}
Angie includes a helper file prometheus_all.conf
that contains a set of commonly used metrics combined into the all
template:File Contents (Angie)
prometheus_template all {
angie_connections_accepted $p8s_value
path=/connections/accepted
type=counter
'help=The total number of accepted client connections.';
angie_connections_dropped $p8s_value
path=/connections/dropped
type=counter
'help=The total number of dropped client connections.';
angie_connections_active $p8s_value
path=/connections/active
type=gauge
'help=The current number of active client connections.';
angie_connections_idle $p8s_value
path=/connections/idle
type=gauge
'help=The current number of idle client connections.';
'angie_slabs_pages_used{zone="$1"}' $p8s_value
path=~^/slabs/([^/]+)/pages/used$
type=gauge
'help=The number of currently used memory pages in a slab zone.';
'angie_slabs_pages_free{zone="$1"}' $p8s_value
path=~^/slabs/([^/]+)/pages/free$
type=gauge
'help=The number of currently free memory pages in a slab zone.';
'angie_slabs_pages_slots_used{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/used$
type=gauge
'help=The number of currently used memory slots of a specific size in a slab zone.';
'angie_slabs_pages_slots_free{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/free$
type=gauge
'help=The number of currently free memory slots of a specific size in a slab zone.';
'angie_slabs_pages_slots_reqs{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/reqs$
type=counter
'help=The total number of attempts to allocate a memory slot of a specific size in a slab zone.';
'angie_slabs_pages_slots_fails{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/fails$
type=counter
'help=The number of unsuccessful attempts to allocate a memory slot of a specific size in a slab zone.';
'angie_resolvers_queries{zone="$1",type="$2"}' $p8s_value
path=~^/resolvers/([^/]+)/queries/([^/]+)$
type=counter
'help=The number of queries of a specific type to resolve in a resolver zone.';
'angie_resolvers_sent{zone="$1",type="$2"}' $p8s_value
path=~^/resolvers/([^/]+)/sent/([^/]+)$
type=counter
'help=The number of sent DNS queries of a specific type to resolve in a resolver zone.';
'angie_resolvers_responses{zone="$1",status="$2"}' $p8s_value
path=~^/resolvers/([^/]+)/responses/([^/]+)$
type=counter
'help=The number of resolution results with a specific status in a resolver zone.';
'angie_http_server_zones_ssl_handshaked{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/ssl/handshaked$
type=counter
'help=The total number of successful SSL handshakes in an HTTP server zone.';
'angie_http_server_zones_ssl_reuses{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/ssl/reuses$
type=counter
'help=The total number of session reuses during SSL handshakes in an HTTP server zone.';
'angie_http_server_zones_ssl_timedout{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/ssl/timedout$
type=counter
'help=The total number of timed-out SSL handshakes in an HTTP server zone.';
'angie_http_server_zones_ssl_failed{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/ssl/failed$
type=counter
'help=The total number of failed SSL handshakes in an HTTP server zone.';
'angie_http_server_zones_requests_total{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/total$
type=counter
'help=The total number of client requests received in an HTTP server zone.';
'angie_http_server_zones_requests_processing{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/processing$
type=gauge
'help=The number of client requests currently being processed in an HTTP server zone.';
'angie_http_server_zones_requests_discarded{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/discarded$
type=counter
'help=The total number of client requests completed in an HTTP server zone without sending a response.';
'angie_http_server_zones_responses{zone="$1",code="$2"}' $p8s_value
path=~^/http/server_zones/([^/]+)/responses/([^/]+)$
type=counter
'help=The number of responses with a specific status in an HTTP server zone.';
'angie_http_server_zones_data_received{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from clients in an HTTP server zone.';
'angie_http_server_zones_data_sent{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to clients in an HTTP server zone.';
'angie_http_location_zones_requests_total{zone="$1"}' $p8s_value
path=~^/http/location_zones/([^/]+)/requests/total$
type=counter
'help=The total number of client requests in an HTTP location zone.';
'angie_http_location_zones_requests_discarded{zone="$1"}' $p8s_value
path=~^/http/location_zones/([^/]+)/requests/discarded$
type=counter
'help=The total number of client requests completed in an HTTP location zone without sending a response.';
'angie_http_location_zones_responses{zone="$1",code="$2"}' $p8s_value
path=~^/http/location_zones/([^/]+)/responses/([^/]+)$
type=counter
'help=The number of responses with a specific status in an HTTP location zone.';
'angie_http_location_zones_data_received{zone="$1"}' $p8s_value
path=~^/http/location_zones/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from clients in an HTTP location zone.';
'angie_http_location_zones_data_sent{zone="$1"}' $p8s_value
path=~^/http/location_zones/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to clients in an HTTP location zone.';
'angie_http_upstreams_peers_state{upstream="$1",peer="$2"}' $p8st_all_ups_state
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/state$
type=gauge
'help=The current state of an upstream peer in "HTTP": 1 - up, 2 - down, 3 - unavailable, or 4 - recovering.';
'angie_http_upstreams_peers_selected_current{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/selected/current$
type=gauge
'help=The number of requests currently being processed by an upstream peer in "HTTP".';
'angie_http_upstreams_peers_selected_total{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/selected/total$
type=counter
'help=The total number of attempts to use an upstream peer in "HTTP".';
'angie_http_upstreams_peers_responses{upstream="$1",peer="$2",code="$3"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/responses/([^/]+)$
type=counter
'help=The number of responses with a specific status received from an upstream peer in "HTTP".';
'angie_http_upstreams_peers_data_sent{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to an upstream peer in "HTTP".';
'angie_http_upstreams_peers_data_received{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from an upstream peer in "HTTP".';
'angie_http_upstreams_peers_health_fails{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/fails$
type=counter
'help=The total number of unsuccessful attempts to communicate with an upstream peer in "HTTP".';
'angie_http_upstreams_peers_health_unavailable{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/unavailable$
type=counter
'help=The number of times when an upstream peer in "HTTP" became "unavailable" due to reaching the max_fails limit.';
'angie_http_upstreams_peers_health_downtime{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/downtime$
type=counter
'help=The total time (in milliseconds) that an upstream peer in "HTTP" was "unavailable".';
'angie_http_upstreams_keepalive{upstream="$1"}' $p8s_value
path=~^/http/upstreams/([^/]+)/keepalive$
type=gauge
'help=The number of currently cached keepalive connections for an HTTP upstream.';
'angie_http_caches_responses{zone="$1",status="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/([^/]+)/responses$
type=counter
'help=The total number of responses processed in an HTTP cache zone with a specific cache status.';
'angie_http_caches_bytes{zone="$1",status="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/([^/]+)/bytes$
type=counter
'help=The total number of bytes processed in an HTTP cache zone with a specific cache status.';
'angie_http_caches_responses_written{zone="$1",status="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/([^/]+)/responses_written$
type=counter
'help=The total number of responses written to an HTTP cache zone with a specific cache status.';
'angie_http_caches_bytes_written{zone="$1",status="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/([^/]+)/bytes_written$
type=counter
'help=The total number of bytes written to an HTTP cache zone with a specific cache status.';
'angie_http_caches_size{zone="$1"}' $p8s_value
path=~^/http/caches/([^/]+)/size$
type=gauge
'help=The current size (in bytes) of cached responses in an HTTP cache zone.';
'angie_http_caches_shards_size{zone="$1",path="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/shards/([^/]+)/size$
type=gauge
'help=The current size (in bytes) of cached responses in a shard path of an HTTP cache zone.';
'angie_http_limit_conns{zone="$1",status="$2"}' $p8s_value
path=~^/http/limit_conns/([^/]+)/([^/]+)$
type=counter
'help=The number of requests processed by an HTTP limit_conn zone with a specific result.';
'angie_http_limit_reqs{zone="$1",status="$2"}' $p8s_value
path=~^/http/limit_reqs/([^/]+)/([^/]+)$
type=counter
'help=The number of requests processed by an HTTP limit_reqs zone with a specific result.';
'angie_stream_server_zones_ssl_handshaked{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/ssl/handshaked$
type=counter
'help=The total number of successful SSL handshakes in a stream server zone.';
'angie_stream_server_zones_ssl_reuses{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/ssl/reuses$
type=counter
'help=The total number of session reuses during SSL handshakes in a stream server zone.';
'angie_stream_server_zones_ssl_timedout{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/ssl/timedout$
type=counter
'help=The total number of timed-out SSL handshakes in a stream server zone.';
'angie_stream_server_zones_ssl_failed{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/ssl/failed$
type=counter
'help=The total number of failed SSL handshakes in a stream server zone.';
'angie_stream_server_zones_connections_total{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/connections/total$
type=counter
'help=The total number of client connections received in a stream server zone.';
'angie_stream_server_zones_connections_processing{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/connections/processing$
type=gauge
'help=The number of client connections currently being processed in a stream server zone.';
'angie_stream_server_zones_connections_discarded{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/connections/discarded$
type=counter
'help=The total number of client connections completed in a stream server zone without establishing a session.';
'angie_stream_server_zones_connections_passed{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/connections/passed$
type=counter
'help=The total number of client connections in a stream server zone passed for handling to a different listening socket.';
'angie_stream_server_zones_sessions{zone="$1",status="$2"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/sessions/([^/]+)$
type=counter
'help=The number of sessions finished with a specific status in a stream server zone.';
'angie_stream_server_zones_data_received{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from clients in a stream server zone.';
'angie_stream_server_zones_data_sent{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to clients in a stream server zone.';
'angie_stream_upstreams_peers_state{upstream="$1",peer="$2"}' $p8st_all_ups_state
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/state$
type=gauge
'help=The current state of an upstream peer in "stream": 1 - up, 2 - down, 3 - unavailable, or 4 - recovering.';
'angie_stream_upstreams_peers_selected_current{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/selected/current$
type=gauge
'help=The number of sessions currently being processed by an upstream peer in "stream".';
'angie_stream_upstreams_peers_selected_total{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/selected/total$
type=counter
'help=The total number of attempts to use an upstream peer in "stream".';
'angie_stream_upstreams_peers_data_sent{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to an upstream peer in "stream".';
'angie_stream_upstreams_peers_data_received{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from an upstream peer in "stream".';
'angie_stream_upstreams_peers_health_fails{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/fails$
type=counter
'help=The total number of unsuccessful attempts to communicate with an upstream peer in "stream".';
'angie_stream_upstreams_peers_health_unavailable{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/unavailable$
type=counter
'help=The number of times when an upstream peer in "stream" became "unavailable" due to reaching the max_fails limit.';
'angie_stream_upstreams_peers_health_downtime{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/downtime$
type=counter
'help=The total time (in milliseconds) that an upstream peer in "stream" was "unavailable".';
}
map $p8s_value $p8st_all_ups_state {
volatile;
"up" 1;
"down" 2;
"unavailable" 3;
"recovering" 4;
# "unhealthy" 5;
# "checking" 6;
# "draining" 7;
"busy" 8;
default 0;
}
File Contents (Angie PRO)
prometheus_template all {
angie_connections_accepted $p8s_value
path=/connections/accepted
type=counter
'help=The total number of accepted client connections.';
angie_connections_dropped $p8s_value
path=/connections/dropped
type=counter
'help=The total number of dropped client connections.';
angie_connections_active $p8s_value
path=/connections/active
type=gauge
'help=The current number of active client connections.';
angie_connections_idle $p8s_value
path=/connections/idle
type=gauge
'help=The current number of idle client connections.';
'angie_slabs_pages_used{zone="$1"}' $p8s_value
path=~^/slabs/([^/]+)/pages/used$
type=gauge
'help=The number of currently used memory pages in a slab zone.';
'angie_slabs_pages_free{zone="$1"}' $p8s_value
path=~^/slabs/([^/]+)/pages/free$
type=gauge
'help=The number of currently free memory pages in a slab zone.';
'angie_slabs_pages_slots_used{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/used$
type=gauge
'help=The number of currently used memory slots of a specific size in a slab zone.';
'angie_slabs_pages_slots_free{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/free$
type=gauge
'help=The number of currently free memory slots of a specific size in a slab zone.';
'angie_slabs_pages_slots_reqs{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/reqs$
type=counter
'help=The total number of attempts to allocate a memory slot of a specific size in a slab zone.';
'angie_slabs_pages_slots_fails{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/fails$
type=counter
'help=The number of unsuccessful attempts to allocate a memory slot of a specific size in a slab zone.';
'angie_resolvers_queries{zone="$1",type="$2"}' $p8s_value
path=~^/resolvers/([^/]+)/queries/([^/]+)$
type=counter
'help=The number of queries of a specific type to resolve in a resolver zone.';
'angie_resolvers_sent{zone="$1",type="$2"}' $p8s_value
path=~^/resolvers/([^/]+)/sent/([^/]+)$
type=counter
'help=The number of sent DNS queries of a specific type to resolve in a resolver zone.';
'angie_resolvers_responses{zone="$1",status="$2"}' $p8s_value
path=~^/resolvers/([^/]+)/responses/([^/]+)$
type=counter
'help=The number of resolution results with a specific status in a resolver zone.';
'angie_http_server_zones_ssl_handshaked{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/ssl/handshaked$
type=counter
'help=The total number of successful SSL handshakes in an HTTP server zone.';
'angie_http_server_zones_ssl_reuses{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/ssl/reuses$
type=counter
'help=The total number of session reuses during SSL handshakes in an HTTP server zone.';
'angie_http_server_zones_ssl_timedout{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/ssl/timedout$
type=counter
'help=The total number of timed-out SSL handshakes in an HTTP server zone.';
'angie_http_server_zones_ssl_failed{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/ssl/failed$
type=counter
'help=The total number of failed SSL handshakes in an HTTP server zone.';
'angie_http_server_zones_requests_total{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/total$
type=counter
'help=The total number of client requests received in an HTTP server zone.';
'angie_http_server_zones_requests_processing{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/processing$
type=gauge
'help=The number of client requests currently being processed in an HTTP server zone.';
'angie_http_server_zones_requests_discarded{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/requests/discarded$
type=counter
'help=The total number of client requests completed in an HTTP server zone without sending a response.';
'angie_http_server_zones_responses{zone="$1",code="$2"}' $p8s_value
path=~^/http/server_zones/([^/]+)/responses/([^/]+)$
type=counter
'help=The number of responses with a specific status in an HTTP server zone.';
'angie_http_server_zones_data_received{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from clients in an HTTP server zone.';
'angie_http_server_zones_data_sent{zone="$1"}' $p8s_value
path=~^/http/server_zones/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to clients in an HTTP server zone.';
'angie_http_location_zones_requests_total{zone="$1"}' $p8s_value
path=~^/http/location_zones/([^/]+)/requests/total$
type=counter
'help=The total number of client requests in an HTTP location zone.';
'angie_http_location_zones_requests_discarded{zone="$1"}' $p8s_value
path=~^/http/location_zones/([^/]+)/requests/discarded$
type=counter
'help=The total number of client requests completed in an HTTP location zone without sending a response.';
'angie_http_location_zones_responses{zone="$1",code="$2"}' $p8s_value
path=~^/http/location_zones/([^/]+)/responses/([^/]+)$
type=counter
'help=The number of responses with a specific status in an HTTP location zone.';
'angie_http_location_zones_data_received{zone="$1"}' $p8s_value
path=~^/http/location_zones/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from clients in an HTTP location zone.';
'angie_http_location_zones_data_sent{zone="$1"}' $p8s_value
path=~^/http/location_zones/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to clients in an HTTP location zone.';
'angie_http_upstreams_peers_backup{upstream="$1",peer="$2"}' $p8st_all_ups_backup
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/backup$
type=gauge
'help=The HTTP upstream peer backup group level.';
'angie_http_upstreams_peers_state{upstream="$1",peer="$2"}' $p8st_all_ups_state
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/state$
type=gauge
'help=The current state of an upstream peer in "HTTP": 1 - up, 2 - down, 3 - unavailable, 4 - recovering, 5 - unhealthy, 6 - checking, or 7 - draining.';
'angie_http_upstreams_peers_selected_current{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/selected/current$
type=gauge
'help=The number of requests currently being processed by an upstream peer in "HTTP".';
'angie_http_upstreams_peers_selected_total{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/selected/total$
type=counter
'help=The total number of attempts to use an upstream peer in "HTTP".';
'angie_http_upstreams_peers_responses{upstream="$1",peer="$2",code="$3"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/responses/([^/]+)$
type=counter
'help=The number of responses with a specific status received from an upstream peer in "HTTP".';
'angie_http_upstreams_peers_data_sent{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to an upstream peer in "HTTP".';
'angie_http_upstreams_peers_data_received{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from an upstream peer in "HTTP".';
'angie_http_upstreams_peers_health_fails{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/fails$
type=counter
'help=The total number of unsuccessful attempts to communicate with an upstream peer in "HTTP".';
'angie_http_upstreams_peers_health_unavailable{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/unavailable$
type=counter
'help=The number of times when an upstream peer in "HTTP" became "unavailable" due to reaching the max_fails limit.';
'angie_http_upstreams_peers_health_downtime{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/downtime$
type=counter
'help=The total time (in milliseconds) that an upstream peer in "HTTP" was "unavailable".';
'angie_http_upstreams_peers_health_header_time{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/header_time$
type=gauge
'help=Average time (in milliseconds) to receive the response headers from an upstream peer in "HTTP".';
'angie_http_upstreams_peers_health_response_time{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/response_time$
type=gauge
'help=Average time (in milliseconds) to receive the complete response from an upstream peer in "HTTP".';
'angie_http_upstreams_peers_health_probes_count{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/probes/count$
type=counter
'help=The total number of probes for this peer.';
'angie_http_upstreams_peers_health_probes_fails{upstream="$1",peer="$2"}' $p8s_value
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/health/probes/fails$
type=counter
'help=The total number of failed probes for this peer.';
'angie_http_upstreams_keepalive{upstream="$1"}' $p8s_value
path=~^/http/upstreams/([^/]+)/keepalive$
type=gauge
'help=The number of currently cached keepalive connections for an HTTP upstream.';
'angie_http_upstreams_backup_switch_active{upstream="$1"}' $p8s_value
path=~^/http/upstreams/([^/]+)/backup_switch/active$
type=gauge
'help=The currently active HTTP upstream servers backup group level.';
'angie_http_upstreams_queue_queued{upstream="$1"}' $p8s_value
path=~^/http/upstreams/([^/]+)/queue/queued$
type=counter
'help=The total number of queued requests for an HTTP upstream.';
'angie_http_upstreams_queue_waiting{upstream="$1"}' $p8s_value
path=~^/http/upstreams/([^/]+)/queue/waiting$
type=gauge
'help=The number of requests currently waiting in an HTTP upstream queue.';
'angie_http_upstreams_queue_dropped{upstream="$1"}' $p8s_value
path=~^/http/upstreams/([^/]+)/queue/dropped$
type=counter
'help=The total number of requests dropped from an HTTP upstream queue because the client had prematurely closed the connection.';
'angie_http_upstreams_queue_timedout{upstream="$1"}' $p8s_value
path=~^/http/upstreams/([^/]+)/queue/timedout$
type=counter
'help=The total number of requests timed out from an HTTP upstream queue.';
'angie_http_upstreams_queue_overflows{upstream="$1"}' $p8s_value
path=~^/http/upstreams/([^/]+)/queue/overflows$
type=counter
'help=The total number of requests rejected by an HTTP upstream queue because the size limit had been reached.';
'angie_http_caches_responses{zone="$1",status="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/([^/]+)/responses$
type=counter
'help=The total number of responses processed in an HTTP cache zone with a specific cache status.';
'angie_http_caches_bytes{zone="$1",status="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/([^/]+)/bytes$
type=counter
'help=The total number of bytes processed in an HTTP cache zone with a specific cache status.';
'angie_http_caches_responses_written{zone="$1",status="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/([^/]+)/responses_written$
type=counter
'help=The total number of responses written to an HTTP cache zone with a specific cache status.';
'angie_http_caches_bytes_written{zone="$1",status="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/([^/]+)/bytes_written$
type=counter
'help=The total number of bytes written to an HTTP cache zone with a specific cache status.';
'angie_http_caches_size{zone="$1"}' $p8s_value
path=~^/http/caches/([^/]+)/size$
type=gauge
'help=The current size (in bytes) of cached responses in an HTTP cache zone.';
'angie_http_caches_shards_size{zone="$1",path="$2"}' $p8s_value
path=~^/http/caches/([^/]+)/shards/([^/]+)/size$
type=gauge
'help=The current size (in bytes) of cached responses in a shard path of an HTTP cache zone.';
'angie_http_limit_conns{zone="$1",status="$2"}' $p8s_value
path=~^/http/limit_conns/([^/]+)/([^/]+)$
type=counter
'help=The number of requests processed by an HTTP limit_conn zone with a specific result.';
'angie_http_limit_reqs{zone="$1",status="$2"}' $p8s_value
path=~^/http/limit_reqs/([^/]+)/([^/]+)$
type=counter
'help=The number of requests processed by an HTTP limit_reqs zone with a specific result.';
'angie_stream_server_zones_ssl_handshaked{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/ssl/handshaked$
type=counter
'help=The total number of successful SSL handshakes in a stream server zone.';
'angie_stream_server_zones_ssl_reuses{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/ssl/reuses$
type=counter
'help=The total number of session reuses during SSL handshakes in a stream server zone.';
'angie_stream_server_zones_ssl_timedout{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/ssl/timedout$
type=counter
'help=The total number of timed-out SSL handshakes in a stream server zone.';
'angie_stream_server_zones_ssl_failed{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/ssl/failed$
type=counter
'help=The total number of failed SSL handshakes in a stream server zone.';
'angie_stream_server_zones_connections_total{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/connections/total$
type=counter
'help=The total number of client connections received in a stream server zone.';
'angie_stream_server_zones_connections_processing{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/connections/processing$
type=gauge
'help=The number of client connections currently being processed in a stream server zone.';
'angie_stream_server_zones_connections_discarded{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/connections/discarded$
type=counter
'help=The total number of client connections completed in a stream server zone without establishing a session.';
'angie_stream_server_zones_connections_passed{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/connections/passed$
type=counter
'help=The total number of client connections in a stream server zone passed for handling to a different listening socket.';
'angie_stream_server_zones_sessions{zone="$1",status="$2"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/sessions/([^/]+)$
type=counter
'help=The number of sessions finished with a specific status in a stream server zone.';
'angie_stream_server_zones_data_received{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from clients in a stream server zone.';
'angie_stream_server_zones_data_sent{zone="$1"}' $p8s_value
path=~^/stream/server_zones/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to clients in a stream server zone.';
'angie_stream_upstreams_peers_backup{upstream="$1",peer="$2"}' $p8st_all_ups_backup
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/backup$
type=gauge
'help=The "stream" upstream peer backup group level.';
'angie_stream_upstreams_peers_state{upstream="$1",peer="$2"}' $p8st_all_ups_state
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/state$
type=gauge
'help=The current state of an upstream peer in "stream": 1 - up, 2 - down, 3 - unavailable, 4 - recovering, 5 - unhealthy, 6 - checking, or 7 - draining.';
'angie_stream_upstreams_peers_selected_current{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/selected/current$
type=gauge
'help=The number of sessions currently being processed by an upstream peer in "stream".';
'angie_stream_upstreams_peers_selected_total{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/selected/total$
type=counter
'help=The total number of attempts to use an upstream peer in "stream".';
'angie_stream_upstreams_peers_data_sent{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/data/sent$
type=counter
'help=The total number of bytes sent to an upstream peer in "stream".';
'angie_stream_upstreams_peers_data_received{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/data/received$
type=counter
'help=The total number of bytes received from an upstream peer in "stream".';
'angie_stream_upstreams_peers_data_pkt_sent{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/data/pkt_sent$
type=counter
'help=The total number of packets sent to an upstream peer in "stream".';
'angie_stream_upstreams_peers_data_pkt_received{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/data/pkt_received$
type=counter
'help=The total number of packets received from an upstream peer in "stream".';
'angie_stream_upstreams_peers_health_fails{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/fails$
type=counter
'help=The total number of unsuccessful attempts to communicate with an upstream peer in "stream".';
'angie_stream_upstreams_peers_health_unavailable{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/unavailable$
type=counter
'help=The number of times when an upstream peer in "stream" became "unavailable" due to reaching the max_fails limit.';
'angie_stream_upstreams_peers_health_downtime{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/downtime$
type=counter
'help=The total time (in milliseconds) that an upstream peer in "stream" was "unavailable".';
'angie_stream_upstreams_peers_health_connect_time{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/connect_time$
type=gauge
'help=Average time (in milliseconds) to connect to an upstream peer in "stream".';
'angie_stream_upstreams_peers_health_first_byte_time{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/first_byte_time$
type=gauge
'help=Average time (in milliseconds) to receive the first byte from an upstream peer in "stream".';
'angie_stream_upstreams_peers_health_last_byte_time{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/last_byte_time$
type=gauge
'help=Average time (in milliseconds) of the whole communication session with an upstream peer in "stream".';
'angie_stream_upstreams_peers_health_probes_count{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/probes/count$
type=counter
'help=The total number of probes for this peer.';
'angie_stream_upstreams_peers_health_probes_fails{upstream="$1",peer="$2"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/peers/([^/]+)/health/probes/fails$
type=counter
'help=The total number of failed probes for this peer.';
'angie_stream_upstreams_backup_switch_active{upstream="$1"}' $p8s_value
path=~^/stream/upstreams/([^/]+)/backup_switch/active$
type=gauge
'help=The currently active "stream" upstream servers backup group level.';
}
map $p8s_value $p8st_all_ups_state {
volatile;
"up" 1;
"down" 2;
"unavailable" 3;
"recovering" 4;
"unhealthy" 5;
"checking" 6;
"draining" 7;
"busy" 8;
default 0;
}
map $p8s_value $p8st_all_ups_backup {
volatile;
"false" 0;
"true" 1;
default $p8s_value;
}
Usage:
http {
include prometheus_all.conf;
# ...
server {
listen 80;
location =/p8s {
prometheus all;
}
# ...
}
}
$ curl localhost/p8s
# Angie Prometheus template "all"
...
Directives#
prometheus#
Specifies a template handler for the location
context,
defined by the prometheus_template directive.
When requested, this location
calculates and returns the template metrics
in Prometheus format.
location =/p8s {
prometheus custom;
}
$ curl localhost/p8s
# Angie Prometheus template "custom"
...
prometheus_template#
Defines a named template of metrics collected and exported by Angie, for use with the prometheus directive.
Note
Angie also includes a ready-made all template that contains a set of the most commonly used metrics.
Can contain any number of metric definitions,
each having the following structure:
<metric_name> <variable> [path=
<match_string>] [type=
<type>] [help=
<help>].
| Sets the metric name
under which it will be added in Prometheus format to the response.
Can contain an optional labels section ( http_requests_total{method="$1",code="$2"}
Label values can use Angie variables; if match_string is defined as a regular expression, you can also use capture groups defined in that expression. Such variables and groups are evaluated when obtaining the metric value, which is set by variable. |
| Sets the name of the variable that will be evaluated and added
as the metric value to the response.
If the variable doesn't exist or the evaluation result is empty ( |
The metric is calculated with the value set by variable; upon successful evaluation, the metric is added to the response, for example:
'angie_time{version="$angie_version"}' $msec;
$ curl localhost/p8s
angie_time{version="1.10.0"} 1695119820.562
| Is matched against all endpoint paths of metrics in the /status API subtree of Angie, allowing multiple instances of the metric to be added to the response at once. |
During matching, paths are taken with the leading slash but without the trailing one,
for example /angie/generation
; matching is case-insensitive.
There are two matching methods:
| Checked by character-by-character comparison. |
| Checked using the PCRE library; can define capture groups for use in the labels of the metric_name field. |
If match_string matches any path,
the value of the Angie metric at that path is stored in the
$p8s_value variable,
which can be used in the variable field when path=
is specified.
In the case of regular expressions, there can be multiple matching paths; the metric is added to the response for each match. Combined with capture groups, this allows obtaining a series of metrics with the same name and different labels, for example:
'angie_slabs_slots_free{zone="$1",size="$2"}' $p8s_value
path=~^/slabs/([^/]+)/slots/([^/]+)/free$;
This definition adds metrics for all zones and all sizes that currently exist in the configuration:
angie_slabs_slots_free{zone="one",size="8"} 502
angie_slabs_slots_free{zone="one",size="16"} 249
angie_slabs_slots_free{zone="one",size="32"} 122
angie_slabs_slots_free{zone="one",size="128"} 22
angie_slabs_slots_free{zone="one",size="512"} 4
angie_slabs_slots_free{zone="two",size="8"} 311
...
If there are no matches (with any matching method), the metric is not added.
Note
The path=
parameter is available only
when Angie is built with the API module.
| Set the metric's type and help string, respectively, in the Prometheus format, which are added with the metric to the response without changes or validation. |
Built-in Variables#
The If the match_string of a metric defined in prometheus_template
matches any path,
the value of the Angie metric located at that path
is stored in the The values of Angie metrics stored in the If the Angie metric has a boolean value, that is http_prometheus
module has a built-in variable
that receives its value when matching metric paths from the
/status
section of the Angie API
with the match_string parameter of metrics defined by the
prometheus_template directive.$p8s_value
#$p8s_value
variable.
It is intended for use in the variable field in metric definitions
that are calculated based on the path=
parameter.$p8s_value
variable
do not always meet the requirements of the Prometheus format.
In such cases, you can use the map directive,
for example to convert strings to numbers:map $p8s_value $ups_state_n {
up 0;
unavailable 1;
down 2;
default 3;
}
prometheus_template main {
'angie_http_upstreams_state{upstream="$1",peer="$2"}' $ups_state_n
path=~^/http/upstreams/([^/]+)/peers/([^/]+)/state$;
}
true
or false
,
the variable receives the value "1"
or "0"
respectively;
if the metric value is null
, the variable will be "(null)"
.
For dates, the integer UNIX epoch format is used.