blob: 1ebeb29cb98354ecad9eb181b2c3ebd51d3cf792 [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
11} -repeat 2 -start
12
William Dauchyb4567442021-02-18 23:05:33 +010013server s2 {
14 rxreq
15 txresp
16} -repeat 2 -start
17
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)
William Dauchy76603f22021-01-10 21:13:06 +010036 server s1 ${s1_addr}:${s1_port}
William Dauchyb4567442021-02-18 23:05:33 +010037 server s2 ${s2_addr}:${s2_port} check maxqueue 10 maxconn 12 pool-max-conn 42
William Dauchy76603f22021-01-10 21:13:06 +010038} -start
39
40client c1 -connect ${h1_stats_sock} {
41 txreq -url "/metrics"
42 rxresp
William Dauchyb4567442021-02-18 23:05:33 +010043 # test general metrics
William Dauchy76603f22021-01-10 21:13:06 +010044 expect resp.status == 200
45 expect resp.body ~ ".*haproxy_process.*"
46 expect resp.body ~ ".*haproxy_frontend.*"
William Dauchye3f7bd52021-02-14 23:22:56 +010047 expect resp.body ~ ".*haproxy_listener.*"
William Dauchy76603f22021-01-10 21:13:06 +010048 expect resp.body ~ ".*haproxy_backend.*"
49 expect resp.body ~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010050 expect resp.body ~ ".*haproxy_sticktable.*"
William Dauchy76603f22021-01-10 21:13:06 +010051
William Dauchyb4567442021-02-18 23:05:33 +010052 # test expected NaN values
53 expect resp.body ~ ".*haproxy_server_check_failures_total{proxy=\"be\",server=\"s1\"} NaN.*"
54 expect resp.body ~ ".*haproxy_server_check_up_down_total{proxy=\"be\",server=\"s1\"} NaN.*"
55 expect resp.body ~ ".*haproxy_server_check_failures_total{proxy=\"be\",server=\"s2\"} 0.*"
56 expect resp.body ~ ".*haproxy_server_check_up_down_total{proxy=\"be\",server=\"s2\"} 0.*"
57
58 expect resp.body ~ ".*haproxy_server_queue_limit{proxy=\"be\",server=\"s1\"} NaN.*"
59 expect resp.body ~ ".*haproxy_server_queue_limit{proxy=\"be\",server=\"s2\"} 10.*"
60
61 expect resp.body ~ ".*haproxy_server_limit_sessions{proxy=\"be\",server=\"s1\"} NaN.*"
62 expect resp.body ~ ".*haproxy_server_limit_sessions{proxy=\"be\",server=\"s2\"} 12.*"
63
64 expect resp.body ~ ".*haproxy_backend_downtime_seconds_total{proxy=\"stats\"} NaN.*"
65 expect resp.body ~ ".*haproxy_backend_downtime_seconds_total{proxy=\"be\"} 0.*"
66 expect resp.body ~ ".*haproxy_server_downtime_seconds_total{proxy=\"be\",server=\"s1\"} NaN.*"
67 expect resp.body ~ ".*haproxy_server_downtime_seconds_total{proxy=\"be\",server=\"s2\"} 0.*"
68
69 expect resp.body ~ ".*haproxy_server_current_throttle{proxy=\"be\",server=\"s1\"} NaN.*"
70
71 expect resp.body ~ ".*haproxy_server_idle_connections_limit{proxy=\"be\",server=\"s1\"} NaN.*"
72 expect resp.body ~ ".*haproxy_server_idle_connections_limit{proxy=\"be\",server=\"s2\"} 42.*"
73
74 # test scope
William Dauchy76603f22021-01-10 21:13:06 +010075 txreq -url "/metrics?scope="
76 rxresp
77 expect resp.status == 200
78 expect resp.bodylen == 0
William Dauchy76603f22021-01-10 21:13:06 +010079
William Dauchy76603f22021-01-10 21:13:06 +010080 txreq -url "/metrics?scope=server"
81 rxresp
82 expect resp.status == 200
83 expect resp.body !~ ".*haproxy_process.*"
84 expect resp.body !~ ".*haproxy_frontend.*"
William Dauchye3f7bd52021-02-14 23:22:56 +010085 expect resp.body !~ ".*haproxy_listener.*"
William Dauchy76603f22021-01-10 21:13:06 +010086 expect resp.body !~ ".*haproxy_backend.*"
87 expect resp.body ~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010088 expect resp.body !~ ".*haproxy_sticktable.*"
William Dauchy76603f22021-01-10 21:13:06 +010089
William Dauchy76603f22021-01-10 21:13:06 +010090 txreq -url "/metrics?scope=frontend&scope=backend"
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 Dauchy1704efe2021-01-11 20:07:48 +010099
100 txreq -url "/metrics?scope"
101 rxresp
102 expect resp.status == 400
William Dauchy76603f22021-01-10 21:13:06 +0100103} -run