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 |
Christopher Faulet | 3d93b5c | 2022-08-24 12:17:31 +0200 | [diff] [blame] | 11 | } -start |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 12 | |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 13 | server s2 { |
| 14 | rxreq |
| 15 | txresp |
Christopher Faulet | 3d93b5c | 2022-08-24 12:17:31 +0200 | [diff] [blame] | 16 | } -start |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 17 | |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 18 | haproxy h1 -conf { |
| 19 | defaults |
| 20 | mode http |
| 21 | timeout connect 1s |
| 22 | timeout client 1s |
| 23 | timeout server 1s |
William Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame] | 24 | option socket-stats |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 25 | |
| 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 Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 35 | stick-table type ip size 1m expire 10s store http_req_rate(10s) |
Christopher Faulet | 3d93b5c | 2022-08-24 12:17:31 +0200 | [diff] [blame] | 36 | option httpchk |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 37 | server s1 ${s1_addr}:${s1_port} |
Christopher Faulet | 3d93b5c | 2022-08-24 12:17:31 +0200 | [diff] [blame] | 38 | server s2 ${s2_addr}:${s2_port} check inter 5s maxqueue 10 maxconn 12 pool-max-conn 42 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 39 | } -start |
| 40 | |
| 41 | client c1 -connect ${h1_stats_sock} { |
| 42 | txreq -url "/metrics" |
| 43 | rxresp |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 44 | # test general metrics |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 45 | expect resp.status == 200 |
| 46 | expect resp.body ~ ".*haproxy_process.*" |
| 47 | expect resp.body ~ ".*haproxy_frontend.*" |
William Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame] | 48 | expect resp.body ~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 49 | expect resp.body ~ ".*haproxy_backend.*" |
| 50 | expect resp.body ~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 51 | expect resp.body ~ ".*haproxy_sticktable.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 52 | |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 53 | # 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 Dauchy | 98ad35f | 2021-02-18 23:05:34 +0100 | [diff] [blame] | 75 | # 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 Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 84 | # test scope |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 85 | txreq -url "/metrics?scope=" |
| 86 | rxresp |
| 87 | expect resp.status == 200 |
| 88 | expect resp.bodylen == 0 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 89 | |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 90 | 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 Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame] | 95 | expect resp.body !~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 96 | expect resp.body !~ ".*haproxy_backend.*" |
| 97 | expect resp.body ~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 98 | expect resp.body !~ ".*haproxy_sticktable.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 99 | |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 100 | 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 Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame] | 105 | expect resp.body !~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 106 | expect resp.body ~ ".*haproxy_backend.*" |
| 107 | expect resp.body !~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 108 | expect resp.body !~ ".*haproxy_sticktable.*" |
William Dauchy | 1704efe | 2021-01-11 20:07:48 +0100 | [diff] [blame] | 109 | |
| 110 | txreq -url "/metrics?scope" |
| 111 | rxresp |
| 112 | expect resp.status == 400 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 113 | } -run |