2021-01-10 20:13:06 +00:00
|
|
|
varnishtest "prometheus exporter test"
|
|
|
|
|
2021-02-07 19:42:38 +00:00
|
|
|
#REQUIRE_VERSION=2.4
|
2021-01-10 20:13:06 +00:00
|
|
|
#REQUIRE_SERVICES=prometheus-exporter
|
|
|
|
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
|
|
|
|
server s1 {
|
|
|
|
rxreq
|
|
|
|
txresp
|
|
|
|
} -repeat 2 -start
|
|
|
|
|
2021-02-18 22:05:33 +00:00
|
|
|
server s2 {
|
|
|
|
rxreq
|
|
|
|
txresp
|
|
|
|
} -repeat 2 -start
|
|
|
|
|
2021-01-10 20:13:06 +00:00
|
|
|
haproxy h1 -conf {
|
|
|
|
defaults
|
|
|
|
mode http
|
2021-11-18 16:46:22 +00:00
|
|
|
timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
|
|
timeout client "${HAPROXY_TEST_TIMEOUT-5s}"
|
|
|
|
timeout server "${HAPROXY_TEST_TIMEOUT-5s}"
|
2021-02-14 22:22:56 +00:00
|
|
|
option socket-stats
|
2021-01-10 20:13:06 +00:00
|
|
|
|
|
|
|
listen stats
|
|
|
|
bind "fd@${stats}"
|
|
|
|
http-request use-service prometheus-exporter if { path /metrics }
|
|
|
|
|
|
|
|
frontend fe
|
|
|
|
bind "fd@${fe}"
|
|
|
|
default_backend be
|
|
|
|
|
|
|
|
backend be
|
2021-02-07 19:42:38 +00:00
|
|
|
stick-table type ip size 1m expire 10s store http_req_rate(10s)
|
2021-01-10 20:13:06 +00:00
|
|
|
server s1 ${s1_addr}:${s1_port}
|
2021-02-18 22:05:33 +00:00
|
|
|
server s2 ${s2_addr}:${s2_port} check maxqueue 10 maxconn 12 pool-max-conn 42
|
2021-01-10 20:13:06 +00:00
|
|
|
} -start
|
|
|
|
|
|
|
|
client c1 -connect ${h1_stats_sock} {
|
|
|
|
txreq -url "/metrics"
|
|
|
|
rxresp
|
2021-02-18 22:05:33 +00:00
|
|
|
# test general metrics
|
2021-01-10 20:13:06 +00:00
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.body ~ ".*haproxy_process.*"
|
|
|
|
expect resp.body ~ ".*haproxy_frontend.*"
|
2021-02-14 22:22:56 +00:00
|
|
|
expect resp.body ~ ".*haproxy_listener.*"
|
2021-01-10 20:13:06 +00:00
|
|
|
expect resp.body ~ ".*haproxy_backend.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server.*"
|
2021-02-07 19:42:38 +00:00
|
|
|
expect resp.body ~ ".*haproxy_sticktable.*"
|
2021-01-10 20:13:06 +00:00
|
|
|
|
2021-02-18 22:05:33 +00:00
|
|
|
# test expected NaN values
|
|
|
|
expect resp.body ~ ".*haproxy_server_check_failures_total{proxy=\"be\",server=\"s1\"} NaN.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_check_up_down_total{proxy=\"be\",server=\"s1\"} NaN.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_check_failures_total{proxy=\"be\",server=\"s2\"} 0.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_check_up_down_total{proxy=\"be\",server=\"s2\"} 0.*"
|
|
|
|
|
|
|
|
expect resp.body ~ ".*haproxy_server_queue_limit{proxy=\"be\",server=\"s1\"} NaN.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_queue_limit{proxy=\"be\",server=\"s2\"} 10.*"
|
|
|
|
|
|
|
|
expect resp.body ~ ".*haproxy_server_limit_sessions{proxy=\"be\",server=\"s1\"} NaN.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_limit_sessions{proxy=\"be\",server=\"s2\"} 12.*"
|
|
|
|
|
|
|
|
expect resp.body ~ ".*haproxy_backend_downtime_seconds_total{proxy=\"stats\"} NaN.*"
|
|
|
|
expect resp.body ~ ".*haproxy_backend_downtime_seconds_total{proxy=\"be\"} 0.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_downtime_seconds_total{proxy=\"be\",server=\"s1\"} NaN.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_downtime_seconds_total{proxy=\"be\",server=\"s2\"} 0.*"
|
|
|
|
|
|
|
|
expect resp.body ~ ".*haproxy_server_current_throttle{proxy=\"be\",server=\"s1\"} NaN.*"
|
|
|
|
|
|
|
|
expect resp.body ~ ".*haproxy_server_idle_connections_limit{proxy=\"be\",server=\"s1\"} NaN.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_idle_connections_limit{proxy=\"be\",server=\"s2\"} 42.*"
|
|
|
|
|
2021-02-18 22:05:34 +00:00
|
|
|
# test well known labels presence
|
|
|
|
expect resp.body ~ ".*haproxy_process_build_info{version=\".*\"} 1.*"
|
|
|
|
expect resp.body ~ ".*haproxy_frontend_http_responses_total{proxy=\"stats\",code=\"4xx\"} 0.*"
|
|
|
|
expect resp.body ~ ".*haproxy_frontend_status{proxy=\"fe\",state=\"UP\"} 1.*"
|
|
|
|
expect resp.body ~ ".*haproxy_listener_status{proxy=\"stats\",listener=\"sock-1\",state=\"WAITING\"} 0.*"
|
|
|
|
expect resp.body ~ ".*haproxy_backend_status{proxy=\"be\",state=\"UP\"} 1.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_status{proxy=\"be\",server=\"s1\",state=\"DOWN\"} 0.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server_check_status{proxy=\"be\",server=\"s2\",state=\"HANA\"} 0.*"
|
|
|
|
|
2021-02-18 22:05:33 +00:00
|
|
|
# test scope
|
2021-01-10 20:13:06 +00:00
|
|
|
txreq -url "/metrics?scope="
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.bodylen == 0
|
|
|
|
|
|
|
|
txreq -url "/metrics?scope=server"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.body !~ ".*haproxy_process.*"
|
|
|
|
expect resp.body !~ ".*haproxy_frontend.*"
|
2021-02-14 22:22:56 +00:00
|
|
|
expect resp.body !~ ".*haproxy_listener.*"
|
2021-01-10 20:13:06 +00:00
|
|
|
expect resp.body !~ ".*haproxy_backend.*"
|
|
|
|
expect resp.body ~ ".*haproxy_server.*"
|
2021-02-07 19:42:38 +00:00
|
|
|
expect resp.body !~ ".*haproxy_sticktable.*"
|
2021-01-10 20:13:06 +00:00
|
|
|
|
|
|
|
txreq -url "/metrics?scope=frontend&scope=backend"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.body !~ ".*haproxy_process.*"
|
|
|
|
expect resp.body ~ ".*haproxy_frontend.*"
|
2021-02-14 22:22:56 +00:00
|
|
|
expect resp.body !~ ".*haproxy_listener.*"
|
2021-01-10 20:13:06 +00:00
|
|
|
expect resp.body ~ ".*haproxy_backend.*"
|
|
|
|
expect resp.body !~ ".*haproxy_server.*"
|
2021-02-07 19:42:38 +00:00
|
|
|
expect resp.body !~ ".*haproxy_sticktable.*"
|
2021-01-11 19:07:48 +00:00
|
|
|
|
|
|
|
txreq -url "/metrics?scope"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 400
|
2021-01-10 20:13:06 +00:00
|
|
|
} -run
|