blob: 766db4773c27b181d73892d4ae8780282a6eecd2 [file] [log] [blame]
William Dauchy76603f22021-01-10 21:13:06 +01001varnishtest "prometheus exporter test"
2
William Dauchy69164222021-02-07 20:42:38 +01003#REQUIRE_VERSION=2.4
William Dauchy76603f22021-01-10 21:13:06 +01004#REQUIRE_SERVICES=prometheus-exporter
5
6feature ignore_unknown_macro
7
8server s1 {
9 rxreq
10 txresp
Christopher Faulet3d93b5c2022-08-24 12:17:31 +020011} -start
William Dauchy76603f22021-01-10 21:13:06 +010012
William Dauchyb4567442021-02-18 23:05:33 +010013server s2 {
14 rxreq
15 txresp
Christopher Faulet3d93b5c2022-08-24 12:17:31 +020016} -start
William Dauchyb4567442021-02-18 23:05:33 +010017
William Dauchy76603f22021-01-10 21:13:06 +010018haproxy h1 -conf {
19 defaults
20 mode http
21 timeout connect 1s
22 timeout client 1s
23 timeout server 1s
William Dauchye3f7bd52021-02-14 23:22:56 +010024 option socket-stats
William Dauchy76603f22021-01-10 21:13:06 +010025
26 listen stats
27 bind "fd@${stats}"
28 http-request use-service prometheus-exporter if { path /metrics }
29
30 frontend fe
31 bind "fd@${fe}"
32 default_backend be
33
34 backend be
William Dauchy69164222021-02-07 20:42:38 +010035 stick-table type ip size 1m expire 10s store http_req_rate(10s)
Christopher Faulet3d93b5c2022-08-24 12:17:31 +020036 option httpchk
William Dauchy76603f22021-01-10 21:13:06 +010037 server s1 ${s1_addr}:${s1_port}
Christopher Faulet3d93b5c2022-08-24 12:17:31 +020038 server s2 ${s2_addr}:${s2_port} check inter 5s maxqueue 10 maxconn 12 pool-max-conn 42
William Dauchy76603f22021-01-10 21:13:06 +010039} -start
40
41client c1 -connect ${h1_stats_sock} {
42 txreq -url "/metrics"
43 rxresp
William Dauchyb4567442021-02-18 23:05:33 +010044 # test general metrics
William Dauchy76603f22021-01-10 21:13:06 +010045 expect resp.status == 200
46 expect resp.body ~ ".*haproxy_process.*"
47 expect resp.body ~ ".*haproxy_frontend.*"
William Dauchye3f7bd52021-02-14 23:22:56 +010048 expect resp.body ~ ".*haproxy_listener.*"
William Dauchy76603f22021-01-10 21:13:06 +010049 expect resp.body ~ ".*haproxy_backend.*"
50 expect resp.body ~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010051 expect resp.body ~ ".*haproxy_sticktable.*"
William Dauchy76603f22021-01-10 21:13:06 +010052
William Dauchyb4567442021-02-18 23:05:33 +010053 # test expected NaN values
54 expect resp.body ~ ".*haproxy_server_check_failures_total{proxy=\"be\",server=\"s1\"} NaN.*"
55 expect resp.body ~ ".*haproxy_server_check_up_down_total{proxy=\"be\",server=\"s1\"} NaN.*"
56 expect resp.body ~ ".*haproxy_server_check_failures_total{proxy=\"be\",server=\"s2\"} 0.*"
57 expect resp.body ~ ".*haproxy_server_check_up_down_total{proxy=\"be\",server=\"s2\"} 0.*"
58
59 expect resp.body ~ ".*haproxy_server_queue_limit{proxy=\"be\",server=\"s1\"} NaN.*"
60 expect resp.body ~ ".*haproxy_server_queue_limit{proxy=\"be\",server=\"s2\"} 10.*"
61
62 expect resp.body ~ ".*haproxy_server_limit_sessions{proxy=\"be\",server=\"s1\"} NaN.*"
63 expect resp.body ~ ".*haproxy_server_limit_sessions{proxy=\"be\",server=\"s2\"} 12.*"
64
65 expect resp.body ~ ".*haproxy_backend_downtime_seconds_total{proxy=\"stats\"} NaN.*"
66 expect resp.body ~ ".*haproxy_backend_downtime_seconds_total{proxy=\"be\"} 0.*"
67 expect resp.body ~ ".*haproxy_server_downtime_seconds_total{proxy=\"be\",server=\"s1\"} NaN.*"
68 expect resp.body ~ ".*haproxy_server_downtime_seconds_total{proxy=\"be\",server=\"s2\"} 0.*"
69
70 expect resp.body ~ ".*haproxy_server_current_throttle{proxy=\"be\",server=\"s1\"} NaN.*"
71
72 expect resp.body ~ ".*haproxy_server_idle_connections_limit{proxy=\"be\",server=\"s1\"} NaN.*"
73 expect resp.body ~ ".*haproxy_server_idle_connections_limit{proxy=\"be\",server=\"s2\"} 42.*"
74
William Dauchy98ad35f2021-02-18 23:05:34 +010075 # test well known labels presence
76 expect resp.body ~ ".*haproxy_process_build_info{version=\".*\"} 1.*"
77 expect resp.body ~ ".*haproxy_frontend_http_responses_total{proxy=\"stats\",code=\"4xx\"} 0.*"
78 expect resp.body ~ ".*haproxy_frontend_status{proxy=\"fe\",state=\"UP\"} 1.*"
79 expect resp.body ~ ".*haproxy_listener_status{proxy=\"stats\",listener=\"sock-1\",state=\"WAITING\"} 0.*"
80 expect resp.body ~ ".*haproxy_backend_status{proxy=\"be\",state=\"UP\"} 1.*"
81 expect resp.body ~ ".*haproxy_server_status{proxy=\"be\",server=\"s1\",state=\"DOWN\"} 0.*"
82 expect resp.body ~ ".*haproxy_server_check_status{proxy=\"be\",server=\"s2\",state=\"HANA\"} 0.*"
83
William Dauchyb4567442021-02-18 23:05:33 +010084 # test scope
William Dauchy76603f22021-01-10 21:13:06 +010085 txreq -url "/metrics?scope="
86 rxresp
87 expect resp.status == 200
88 expect resp.bodylen == 0
William Dauchy76603f22021-01-10 21:13:06 +010089
William Dauchy76603f22021-01-10 21:13:06 +010090 txreq -url "/metrics?scope=server"
91 rxresp
92 expect resp.status == 200
93 expect resp.body !~ ".*haproxy_process.*"
94 expect resp.body !~ ".*haproxy_frontend.*"
William Dauchye3f7bd52021-02-14 23:22:56 +010095 expect resp.body !~ ".*haproxy_listener.*"
William Dauchy76603f22021-01-10 21:13:06 +010096 expect resp.body !~ ".*haproxy_backend.*"
97 expect resp.body ~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010098 expect resp.body !~ ".*haproxy_sticktable.*"
William Dauchy76603f22021-01-10 21:13:06 +010099
William Dauchy76603f22021-01-10 21:13:06 +0100100 txreq -url "/metrics?scope=frontend&scope=backend"
101 rxresp
102 expect resp.status == 200
103 expect resp.body !~ ".*haproxy_process.*"
104 expect resp.body ~ ".*haproxy_frontend.*"
William Dauchye3f7bd52021-02-14 23:22:56 +0100105 expect resp.body !~ ".*haproxy_listener.*"
William Dauchy76603f22021-01-10 21:13:06 +0100106 expect resp.body ~ ".*haproxy_backend.*"
107 expect resp.body !~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +0100108 expect resp.body !~ ".*haproxy_sticktable.*"
William Dauchy1704efe2021-01-11 20:07:48 +0100109
110 txreq -url "/metrics?scope"
111 rxresp
112 expect resp.status == 400
William Dauchy76603f22021-01-10 21:13:06 +0100113} -run