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 | |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 13 | server s2 { |
| 14 | rxreq |
| 15 | txresp |
| 16 | } -repeat 2 -start |
| 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) |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 36 | server s1 ${s1_addr}:${s1_port} |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 37 | server s2 ${s2_addr}:${s2_port} check maxqueue 10 maxconn 12 pool-max-conn 42 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 38 | } -start |
| 39 | |
| 40 | client c1 -connect ${h1_stats_sock} { |
| 41 | txreq -url "/metrics" |
| 42 | rxresp |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 43 | # test general metrics |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 44 | expect resp.status == 200 |
| 45 | expect resp.body ~ ".*haproxy_process.*" |
| 46 | expect resp.body ~ ".*haproxy_frontend.*" |
William Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame] | 47 | expect resp.body ~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 48 | expect resp.body ~ ".*haproxy_backend.*" |
| 49 | expect resp.body ~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 50 | expect resp.body ~ ".*haproxy_sticktable.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 51 | |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 52 | # 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 | |
William Dauchy | 98ad35f | 2021-02-18 23:05:34 +0100 | [diff] [blame] | 74 | # test well known labels presence |
| 75 | expect resp.body ~ ".*haproxy_process_build_info{version=\".*\"} 1.*" |
| 76 | expect resp.body ~ ".*haproxy_frontend_http_responses_total{proxy=\"stats\",code=\"4xx\"} 0.*" |
| 77 | expect resp.body ~ ".*haproxy_frontend_status{proxy=\"fe\",state=\"UP\"} 1.*" |
| 78 | expect resp.body ~ ".*haproxy_listener_status{proxy=\"stats\",listener=\"sock-1\",state=\"WAITING\"} 0.*" |
| 79 | expect resp.body ~ ".*haproxy_backend_status{proxy=\"be\",state=\"UP\"} 1.*" |
| 80 | expect resp.body ~ ".*haproxy_server_status{proxy=\"be\",server=\"s1\",state=\"DOWN\"} 0.*" |
| 81 | expect resp.body ~ ".*haproxy_server_check_status{proxy=\"be\",server=\"s2\",state=\"HANA\"} 0.*" |
| 82 | |
William Dauchy | b456744 | 2021-02-18 23:05:33 +0100 | [diff] [blame] | 83 | # test scope |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 84 | txreq -url "/metrics?scope=" |
| 85 | rxresp |
| 86 | expect resp.status == 200 |
| 87 | expect resp.bodylen == 0 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 88 | |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 89 | txreq -url "/metrics?scope=server" |
| 90 | rxresp |
| 91 | expect resp.status == 200 |
| 92 | expect resp.body !~ ".*haproxy_process.*" |
| 93 | expect resp.body !~ ".*haproxy_frontend.*" |
William Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame] | 94 | expect resp.body !~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 95 | expect resp.body !~ ".*haproxy_backend.*" |
| 96 | expect resp.body ~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 97 | expect resp.body !~ ".*haproxy_sticktable.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 98 | |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 99 | txreq -url "/metrics?scope=frontend&scope=backend" |
| 100 | rxresp |
| 101 | expect resp.status == 200 |
| 102 | expect resp.body !~ ".*haproxy_process.*" |
| 103 | expect resp.body ~ ".*haproxy_frontend.*" |
William Dauchy | e3f7bd5 | 2021-02-14 23:22:56 +0100 | [diff] [blame] | 104 | expect resp.body !~ ".*haproxy_listener.*" |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 105 | expect resp.body ~ ".*haproxy_backend.*" |
| 106 | expect resp.body !~ ".*haproxy_server.*" |
William Dauchy | 6916422 | 2021-02-07 20:42:38 +0100 | [diff] [blame] | 107 | expect resp.body !~ ".*haproxy_sticktable.*" |
William Dauchy | 1704efe | 2021-01-11 20:07:48 +0100 | [diff] [blame] | 108 | |
| 109 | txreq -url "/metrics?scope" |
| 110 | rxresp |
| 111 | expect resp.status == 400 |
William Dauchy | 76603f2 | 2021-01-10 21:13:06 +0100 | [diff] [blame] | 112 | } -run |