blob: cdd0f0f5588940d9fb711e0b31fd6a20239aa703 [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
13haproxy h1 -conf {
14 defaults
15 mode http
16 timeout connect 1s
17 timeout client 1s
18 timeout server 1s
William Dauchye3f7bd52021-02-14 23:22:56 +010019 option socket-stats
William Dauchy76603f22021-01-10 21:13:06 +010020
21 listen stats
22 bind "fd@${stats}"
23 http-request use-service prometheus-exporter if { path /metrics }
24
25 frontend fe
26 bind "fd@${fe}"
27 default_backend be
28
29 backend be
William Dauchy69164222021-02-07 20:42:38 +010030 stick-table type ip size 1m expire 10s store http_req_rate(10s)
William Dauchy76603f22021-01-10 21:13:06 +010031 server s1 ${s1_addr}:${s1_port}
32} -start
33
34client c1 -connect ${h1_stats_sock} {
35 txreq -url "/metrics"
36 rxresp
37 expect resp.status == 200
38 expect resp.body ~ ".*haproxy_process.*"
39 expect resp.body ~ ".*haproxy_frontend.*"
William Dauchye3f7bd52021-02-14 23:22:56 +010040 expect resp.body ~ ".*haproxy_listener.*"
William Dauchy76603f22021-01-10 21:13:06 +010041 expect resp.body ~ ".*haproxy_backend.*"
42 expect resp.body ~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010043 expect resp.body ~ ".*haproxy_sticktable.*"
William Dauchy76603f22021-01-10 21:13:06 +010044
William Dauchy76603f22021-01-10 21:13:06 +010045 txreq -url "/metrics?scope="
46 rxresp
47 expect resp.status == 200
48 expect resp.bodylen == 0
William Dauchy76603f22021-01-10 21:13:06 +010049
William Dauchy76603f22021-01-10 21:13:06 +010050 txreq -url "/metrics?scope=server"
51 rxresp
52 expect resp.status == 200
53 expect resp.body !~ ".*haproxy_process.*"
54 expect resp.body !~ ".*haproxy_frontend.*"
William Dauchye3f7bd52021-02-14 23:22:56 +010055 expect resp.body !~ ".*haproxy_listener.*"
William Dauchy76603f22021-01-10 21:13:06 +010056 expect resp.body !~ ".*haproxy_backend.*"
57 expect resp.body ~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010058 expect resp.body !~ ".*haproxy_sticktable.*"
William Dauchy76603f22021-01-10 21:13:06 +010059
William Dauchy76603f22021-01-10 21:13:06 +010060 txreq -url "/metrics?scope=frontend&scope=backend"
61 rxresp
62 expect resp.status == 200
63 expect resp.body !~ ".*haproxy_process.*"
64 expect resp.body ~ ".*haproxy_frontend.*"
William Dauchye3f7bd52021-02-14 23:22:56 +010065 expect resp.body !~ ".*haproxy_listener.*"
William Dauchy76603f22021-01-10 21:13:06 +010066 expect resp.body ~ ".*haproxy_backend.*"
67 expect resp.body !~ ".*haproxy_server.*"
William Dauchy69164222021-02-07 20:42:38 +010068 expect resp.body !~ ".*haproxy_sticktable.*"
William Dauchy1704efe2021-01-11 20:07:48 +010069
70 txreq -url "/metrics?scope"
71 rxresp
72 expect resp.status == 400
William Dauchy76603f22021-01-10 21:13:06 +010073} -run