jonnenauha / prometheus_varnish_exporter

Varnish exporter for Prometheus
MIT License
177 stars 101 forks source link

Exporter reports backend_up backend_happy as 0 though they are up #82

Open xrow opened 2 years ago

xrow commented 2 years ago

I have the feeling there is a logic error in https://github.com/jonnenauha/prometheus_varnish_exporter/blob/86fc1b025dd41eaf43a583a262daec6cad69b561/varnish.go#L187

In my example I have one healty backend reported by varnishadm backend.list -p. The backup_up is 0 though since backend_happy is also 0 since there is no probe. The failed backends is also 0.


sh-5.1$ varnishadm backend.list -p
200
Backend name   Admin      Probe    Health     Last change
boot.default   healthy    0/0      healthy    Thu, 01 Sep 2022 14:59:49 GMT
sh-5.1# varnishstat -1 | grep VBE.boot.default
VBE.boot.default.happy                        0          .   Happy health probes
VBE.boot.default.bereq_hdrbytes           16896         0.22 Request header bytes
VBE.boot.default.bereq_bodybytes            180         0.00 Request body bytes
VBE.boot.default.beresp_hdrbytes          11632         0.15 Response header bytes
VBE.boot.default.beresp_bodybytes       1037775        13.62 Response body bytes
VBE.boot.default.pipe_hdrbytes                0         0.00 Pipe request header bytes
VBE.boot.default.pipe_out                     0         0.00 Piped bytes to backend
VBE.boot.default.pipe_in                      0         0.00 Piped bytes from backend
VBE.boot.default.conn                         0          .   Concurrent connections used
VBE.boot.default.req                         25         0.00 Backend requests sent
VBE.boot.default.unhealthy                    0         0.00 Fetches not attempted due to backend being unhealthy
VBE.boot.default.busy                         0         0.00 Fetches not attempted due to backend being busy
VBE.boot.default.fail                         0         0.00 Connections failed
VBE.boot.default.fail_eacces                  0         0.00 Connections failed with EACCES or EPERM
VBE.boot.default.fail_eaddrnotavail            0         0.00 Connections failed with EADDRNOTAVAIL
VBE.boot.default.fail_econnrefused             0         0.00 Connections failed with ECONNREFUSED
VBE.boot.default.fail_enetunreach              0         0.00 Connections failed with ENETUNREACH
VBE.boot.default.fail_etimedout                0         0.00 Connections failed ETIMEDOUT
VBE.boot.default.fail_other                    0         0.00 Connections failed for other reason
VBE.boot.default.helddown                      0         0.00 Connection opens not attempted
sh-5.1# curl localhost:9131/metrics | grep backend_
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0# HELP varnish_backend_bereq_bodybytes Request body bytes
# TYPE varnish_backend_bereq_bodybytes counter
varnish_backend_bereq_bodybytes{backend="default",server="unknown"} 180
# HELP varnish_backend_bereq_hdrbytes Request header bytes
# TYPE varnish_backend_bereq_hdrbytes counter
varnish_backend_bereq_hdrbytes{backend="default",server="unknown"} 16896
# HELP varnish_backend_beresp_bodybytes Response body bytes
# TYPE varnish_backend_beresp_bodybytes counter
varnish_backend_beresp_bodybytes{backend="default",server="unknown"} 1.037775e+06
# HELP varnish_backend_beresp_hdrbytes Response header bytes
# TYPE varnish_backend_beresp_hdrbytes counter
varnish_backend_beresp_hdrbytes{backend="default",server="unknown"} 11632
# HELP varnish_backend_busy Fetches not attempted due to backend being busy
# TYPE varnish_backend_busy counter
varnish_backend_busy{backend="default",server="unknown"} 0
# HELP varnish_backend_conn Concurrent connections used
# TYPE varnish_backend_conn gauge
varnish_backend_conn{backend="default",server="unknown"} 0
# HELP varnish_backend_fail Connections failed
# TYPE varnish_backend_fail counter
varnish_backend_fail{backend="default",server="unknown"} 0
# HELP varnish_backend_fail_eacces Connections failed with EACCES or EPERM
# TYPE varnish_backend_fail_eacces counter
varnish_backend_fail_eacces{backend="default",server="unknown"} 0
# HELP varnish_backend_fail_eaddrnotavail Connections failed with EADDRNOTAVAIL
# TYPE varnish_backend_fail_eaddrnotavail counter
varnish_backend_fail_eaddrnotavail{backend="default",server="unknown"} 0
# HELP varnish_backend_fail_econnrefused Connections failed with ECONNREFUSED
# TYPE varnish_backend_fail_econnrefused counter
varnish_backend_fail_econnrefused{backend="default",server="unknown"} 0
# HELP varnish_backend_fail_enetunreach Connections failed with ENETUNREACH
# TYPE varnish_backend_fail_enetunreach counter
varnish_backend_fail_enetunreach{backend="default",server="unknown"} 0
# HELP varnish_backend_fail_etimedout Connections failed ETIMEDOUT
# TYPE varnish_backend_fail_etimedout counter
varnish_backend_fail_etimedout{backend="default",server="unknown"} 0
# HELP varnish_backend_fail_other Connections failed for other reason
# TYPE varnish_backend_fail_other counter
varnish_backend_fail_other{backend="default",server="unknown"} 0
# HELP varnish_backend_happy Happy health probes
# TYPE varnish_backend_happy gauge
varnish_backend_happy{backend="default",server="unknown"} 0
# HELP varnish_backend_helddown Connection opens not attempted
# TYPE varnish_backend_helddown counter
varnish_backend_helddown{backend="default",server="unknown"} 0
# HELP varnish_backend_pipe_hdrbytes Pipe request header bytes
# TYPE varnish_backend_pipe_hdrbytes counter
varnish_backend_pipe_hdrbytes{backend="default",server="unknown"} 0
# HELP varnish_backend_pipe_in Piped bytes from backend
# TYPE varnish_backend_pipe_in counter
varnish_backend_pipe_in{backend="default",server="unknown"} 0
# HELP varnish_backend_pipe_out Piped bytes to backend
# TYPE varnish_backend_pipe_out counter
varnish_backend_pipe_out{backend="default",server="unknown"} 0
# HELP varnish_backend_req Backend requests sent
# TYPE varnish_backend_req counter
varnish_backend_req{backend="default",server="unknown"} 25
# HELP varnish_backend_unhealthy Fetches not attempted due to backend being unhealthy
# TYPE varnish_backend_unhealthy counter
varnish_backend_unhealthy{backend="default",server="unknown"} 0
# HELP varnish_backend_up Backend up as per the latest health probe
# TYPE varnish_backend_up gauge
varnish_backend_up{backend="default",server="unknown"} 0
# HELP varnish_main_backend_busy Backend conn. too many
# TYPE varnish_main_backend_busy counter
varnish_main_backend_busy 0
# HELP varnish_main_backend_conn Backend conn. success
# TYPE varnish_main_backend_conn counter
varnish_main_backend_conn 25
# HELP varnish_main_backend_fail Backend conn. failures
# TYPE varnish_main_backend_fail counter
varnish_main_backend_fail 0
# HELP varnish_main_backend_recycle Backend conn. recycles
# TYPE varnish_main_backend_recycle counter
varnish_main_backend_recycle 0
# HELP varnish_main_backend_req Backend requests made
# TYPE varnish_main_backend_req counter
varnish_main_backend_req 25
# HELP varnish_main_backend_retry Backend conn. retry
# TYPE varnish_main_backend_retry counter
varnish_main_backend_retry 0
# HELP varnish_main_backend_reuse Backend conn. reuses
# TYPE varnish_main_backend_reuse counter
varnish_main_backend_reuse 0
# HELP varnish_main_backend_unhealthy Backend conn. not attempted
# TYPE varnish_main_backend_unhealthy counter
varnish_main_backend_unhealthy 0
# HELP varnish_main_ws_backend_overflow workspace_backend overflows
# TYPE varnish_main_ws_backend_overflow counter
varnish_main_ws_backend_overflow 0
100 30746    0 30746    0     0  1876k      0 --:--:-- --:--:-- --:--:-- 1876k
launtony commented 1 year ago

Hi, I have the same issue with varnish 6.0.11 who's running into docker... Thanks,

hashworks commented 4 months ago

Couldn't reproduce this, any idea?

varnish_backend_up{backend="backend01",server="unknown"} 1
varnish_backend_up{backend="backend02",server="unknown"} 1
varnish_backend_up{backend="backend03",server="unknown"} 1
varnish_backend_up{backend="test_unhappy",server="unknown"} 0