William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 1 | varnishtest "prometheus exporter test" |
| 2 | |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 3 | #REQUIRE_VERSION=2.4 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 4 | #REQUIRE_SERVICES=prometheus-exporter |
| 5 | |
| 6 | feature ignore_unknown_macro |
| 7 | |
| 8 | server s1 { |
| 9 | rxreq |
| 10 | txresp |
| 11 | } -repeat 2 -start |
| 12 | |
| 13 | haproxy h1 -conf { |
| 14 | defaults |
| 15 | mode http |
| 16 | timeout connect 1s |
| 17 | timeout client 1s |
| 18 | timeout server 1s |
William Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame^] | 19 | option socket-stats |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 20 | |
| 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 Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 30 | stick-table type ip size 1m expire 10s store http_req_rate(10s) |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 31 | server s1 ${s1_addr}:${s1_port} |
| 32 | } -start |
| 33 | |
| 34 | client 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 Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame^] | 40 | expect resp.body ~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 41 | expect resp.body ~ ".*haproxy_backend.*" |
| 42 | expect resp.body ~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 43 | expect resp.body ~ ".*haproxy_sticktable.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 44 | |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 45 | txreq -url "/metrics?scope=" |
| 46 | rxresp |
| 47 | expect resp.status == 200 |
| 48 | expect resp.bodylen == 0 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 49 | |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 50 | 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 Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame^] | 55 | expect resp.body !~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 56 | expect resp.body !~ ".*haproxy_backend.*" |
| 57 | expect resp.body ~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 58 | expect resp.body !~ ".*haproxy_sticktable.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 59 | |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 60 | 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 Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame^] | 65 | expect resp.body !~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 66 | expect resp.body ~ ".*haproxy_backend.*" |
| 67 | expect resp.body !~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 68 | expect resp.body !~ ".*haproxy_sticktable.*" |
William Dauchy | 1704efe | 2021-01-11 20:07:48 +0100 | [diff] [blame] | 69 | |
| 70 | txreq -url "/metrics?scope" |
| 71 | rxresp |
| 72 | expect resp.status == 400 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 73 | } -run |