From 46fa8a3f800d8cc2e0c95d0582aee50602f53633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20W=C3=BCrbach?= Date: Wed, 30 Sep 2020 22:57:55 +0200 Subject: [PATCH] Support varnish 6.5+ --- test/scrape/6.5.1.json | 2094 ++++++++++++++++++++++++++++++++++++++++ varnish.go | 10 +- varnish_test.go | 21 +- 3 files changed, 2118 insertions(+), 7 deletions(-) create mode 100644 test/scrape/6.5.1.json diff --git a/test/scrape/6.5.1.json b/test/scrape/6.5.1.json new file mode 100644 index 0000000..58e8ada --- /dev/null +++ b/test/scrape/6.5.1.json @@ -0,0 +1,2094 @@ +{ + "version": 1, + "timestamp": "2020-09-30T20:38:25", + "counters": { + "MGT.uptime": { + "description": "Management process uptime", + "flag": "c", + "format": "d", + "value": 112 + }, + "MGT.child_start": { + "description": "Child process started", + "flag": "c", + "format": "i", + "value": 1 + }, + "MGT.child_exit": { + "description": "Child process normal exit", + "flag": "c", + "format": "i", + "value": 0 + }, + "MGT.child_stop": { + "description": "Child process unexpected exit", + "flag": "c", + "format": "i", + "value": 0 + }, + "MGT.child_died": { + "description": "Child process died (signal)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MGT.child_dump": { + "description": "Child process core dumped", + "flag": "c", + "format": "i", + "value": 0 + }, + "MGT.child_panic": { + "description": "Child process panic", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.summs": { + "description": "stat summ operations", + "flag": "c", + "format": "i", + "value": 138 + }, + "MAIN.uptime": { + "description": "Child process uptime", + "flag": "c", + "format": "d", + "value": 113 + }, + "MAIN.sess_conn": { + "description": "Sessions accepted", + "flag": "c", + "format": "i", + "value": 43 + }, + "MAIN.sess_fail": { + "description": "Session accept failures", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_fail_econnaborted": { + "description": "Session accept failures: connection aborted", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_fail_eintr": { + "description": "Session accept failures: interrupted system call", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_fail_emfile": { + "description": "Session accept failures: too many open files", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_fail_ebadf": { + "description": "Session accept failures: bad file descriptor", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_fail_enomem": { + "description": "Session accept failures: not enough memory", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_fail_other": { + "description": "Session accept failures: other", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.client_req_400": { + "description": "Client requests received, subject to 400 errors", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.client_req_417": { + "description": "Client requests received, subject to 417 errors", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.client_req": { + "description": "Good client requests received", + "flag": "c", + "format": "i", + "value": 43 + }, + "MAIN.cache_hit": { + "description": "Cache hits", + "flag": "c", + "format": "i", + "value": 11 + }, + "MAIN.cache_hit_grace": { + "description": "Cache grace hits", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.cache_hitpass": { + "description": "Cache hits for pass.", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.cache_hitmiss": { + "description": "Cache hits for miss.", + "flag": "c", + "format": "i", + "value": 2 + }, + "MAIN.cache_miss": { + "description": "Cache misses", + "flag": "c", + "format": "i", + "value": 26 + }, + "MAIN.beresp_uncacheable": { + "description": "Uncacheable backend responses", + "flag": "c", + "format": "i", + "value": 5 + }, + "MAIN.beresp_shortlived": { + "description": "Shortlived objects", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.backend_conn": { + "description": "Backend conn. success", + "flag": "c", + "format": "i", + "value": 3 + }, + "MAIN.backend_unhealthy": { + "description": "Backend conn. not attempted", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.backend_busy": { + "description": "Backend conn. too many", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.backend_fail": { + "description": "Backend conn. failures", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.backend_reuse": { + "description": "Backend conn. reuses", + "flag": "c", + "format": "i", + "value": 24 + }, + "MAIN.backend_recycle": { + "description": "Backend conn. recycles", + "flag": "c", + "format": "i", + "value": 26 + }, + "MAIN.backend_retry": { + "description": "Backend conn. retry", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_head": { + "description": "Fetch no body (HEAD)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_length": { + "description": "Fetch with Length", + "flag": "c", + "format": "i", + "value": 27 + }, + "MAIN.fetch_chunked": { + "description": "Fetch chunked", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_eof": { + "description": "Fetch EOF", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_bad": { + "description": "Fetch bad T-E", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_none": { + "description": "Fetch no body", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_1xx": { + "description": "Fetch no body (1xx)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_204": { + "description": "Fetch no body (204)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_304": { + "description": "Fetch no body (304)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_failed": { + "description": "Fetch failed (all causes)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.fetch_no_thread": { + "description": "Fetch failed (no thread)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.pools": { + "description": "Number of thread pools", + "flag": "g", + "format": "i", + "value": 2 + }, + "MAIN.threads": { + "description": "Total number of threads", + "flag": "g", + "format": "i", + "value": 200 + }, + "MAIN.threads_limited": { + "description": "Threads hit max", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.threads_created": { + "description": "Threads created", + "flag": "c", + "format": "i", + "value": 200 + }, + "MAIN.threads_destroyed": { + "description": "Threads destroyed", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.threads_failed": { + "description": "Thread creation failed", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.thread_queue_len": { + "description": "Length of session queue", + "flag": "g", + "format": "i", + "value": 0 + }, + "MAIN.busy_sleep": { + "description": "Number of requests sent to sleep on busy objhdr", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.busy_wakeup": { + "description": "Number of requests woken after sleep on busy objhdr", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.busy_killed": { + "description": "Number of requests killed after sleep on busy objhdr", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_queued": { + "description": "Sessions queued for thread", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_dropped": { + "description": "Sessions dropped for thread", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.req_dropped": { + "description": "Requests dropped", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.n_object": { + "description": "object structs made", + "flag": "g", + "format": "i", + "value": 10 + }, + "MAIN.n_vampireobject": { + "description": "unresurrected objects", + "flag": "g", + "format": "i", + "value": 0 + }, + "MAIN.n_objectcore": { + "description": "objectcore structs made", + "flag": "g", + "format": "i", + "value": 10 + }, + "MAIN.n_objecthead": { + "description": "objecthead structs made", + "flag": "g", + "format": "i", + "value": 18 + }, + "MAIN.n_backend": { + "description": "Number of backends", + "flag": "g", + "format": "i", + "value": 1 + }, + "MAIN.n_expired": { + "description": "Number of expired objects", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.n_lru_nuked": { + "description": "Number of LRU nuked objects", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.n_lru_moved": { + "description": "Number of LRU moved objects", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.n_lru_limited": { + "description": "Reached nuke_limit", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.losthdr": { + "description": "HTTP header overflows", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.s_sess": { + "description": "Total sessions seen", + "flag": "c", + "format": "i", + "value": 43 + }, + "MAIN.n_pipe": { + "description": "Number of ongoing pipe sessions", + "flag": "g", + "format": "i", + "value": 0 + }, + "MAIN.pipe_limited": { + "description": "Pipes hit pipe_sess_max", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.s_pipe": { + "description": "Total pipe sessions seen", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.s_pass": { + "description": "Total pass-ed requests seen", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.s_fetch": { + "description": "Total backend fetches initiated", + "flag": "c", + "format": "i", + "value": 26 + }, + "MAIN.s_synth": { + "description": "Total synthetic responses made", + "flag": "c", + "format": "i", + "value": 6 + }, + "MAIN.s_req_hdrbytes": { + "description": "Request header bytes", + "flag": "c", + "format": "B", + "value": 6791 + }, + "MAIN.s_req_bodybytes": { + "description": "Request body bytes", + "flag": "c", + "format": "B", + "value": 0 + }, + "MAIN.s_resp_hdrbytes": { + "description": "Response header bytes", + "flag": "c", + "format": "B", + "value": 12350 + }, + "MAIN.s_resp_bodybytes": { + "description": "Response body bytes", + "flag": "c", + "format": "B", + "value": 77 + }, + "MAIN.s_pipe_hdrbytes": { + "description": "Pipe request header bytes", + "flag": "c", + "format": "B", + "value": 0 + }, + "MAIN.s_pipe_in": { + "description": "Piped bytes from client", + "flag": "c", + "format": "B", + "value": 0 + }, + "MAIN.s_pipe_out": { + "description": "Piped bytes to client", + "flag": "c", + "format": "B", + "value": 0 + }, + "MAIN.sess_closed": { + "description": "Session Closed", + "flag": "c", + "format": "i", + "value": 43 + }, + "MAIN.sess_closed_err": { + "description": "Session Closed with error", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_readahead": { + "description": "Session Read Ahead", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sess_herd": { + "description": "Session herd", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_rem_close": { + "description": "Session OK REM_CLOSE", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_req_close": { + "description": "Session OK REQ_CLOSE", + "flag": "c", + "format": "i", + "value": 43 + }, + "MAIN.sc_req_http10": { + "description": "Session Err REQ_HTTP10", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_rx_bad": { + "description": "Session Err RX_BAD", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_rx_body": { + "description": "Session Err RX_BODY", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_rx_junk": { + "description": "Session Err RX_JUNK", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_rx_overflow": { + "description": "Session Err RX_OVERFLOW", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_rx_timeout": { + "description": "Session Err RX_TIMEOUT", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_rx_close_idle": { + "description": "Session Err RX_CLOSE_IDLE", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_tx_pipe": { + "description": "Session OK TX_PIPE", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_tx_error": { + "description": "Session Err TX_ERROR", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_tx_eof": { + "description": "Session OK TX_EOF", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_resp_close": { + "description": "Session OK RESP_CLOSE", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_overload": { + "description": "Session Err OVERLOAD", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_pipe_overflow": { + "description": "Session Err PIPE_OVERFLOW", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_range_short": { + "description": "Session Err RANGE_SHORT", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_req_http20": { + "description": "Session Err REQ_HTTP20", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.sc_vcl_failure": { + "description": "Session Err VCL_FAILURE", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.client_resp_500": { + "description": "Delivery failed due to insufficient workspace.", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.ws_backend_overflow": { + "description": "workspace_backend overflows", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.ws_client_overflow": { + "description": "workspace_client overflows", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.ws_thread_overflow": { + "description": "workspace_thread overflows", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.ws_session_overflow": { + "description": "workspace_session overflows", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.shm_records": { + "description": "SHM records", + "flag": "c", + "format": "i", + "value": 3487 + }, + "MAIN.shm_writes": { + "description": "SHM writes", + "flag": "c", + "format": "i", + "value": 400 + }, + "MAIN.shm_flushes": { + "description": "SHM flushes due to overflow", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.shm_cont": { + "description": "SHM MTX contention", + "flag": "c", + "format": "i", + "value": 3 + }, + "MAIN.shm_cycles": { + "description": "SHM cycles through buffer", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.backend_req": { + "description": "Backend requests made", + "flag": "c", + "format": "i", + "value": 27 + }, + "MAIN.n_vcl": { + "description": "Number of loaded VCLs in total", + "flag": "g", + "format": "i", + "value": 1 + }, + "MAIN.n_vcl_avail": { + "description": "Number of VCLs available", + "flag": "g", + "format": "i", + "value": 1 + }, + "MAIN.n_vcl_discard": { + "description": "Number of discarded VCLs", + "flag": "g", + "format": "i", + "value": 0 + }, + "MAIN.vcl_fail": { + "description": "VCL failures", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.bans": { + "description": "Count of bans", + "flag": "g", + "format": "i", + "value": 1 + }, + "MAIN.bans_completed": { + "description": "Number of bans marked 'completed'", + "flag": "g", + "format": "i", + "value": 1 + }, + "MAIN.bans_obj": { + "description": "Number of bans using obj.*", + "flag": "g", + "format": "i", + "value": 1 + }, + "MAIN.bans_req": { + "description": "Number of bans using req.*", + "flag": "g", + "format": "i", + "value": 0 + }, + "MAIN.bans_added": { + "description": "Bans added", + "flag": "c", + "format": "i", + "value": 7 + }, + "MAIN.bans_deleted": { + "description": "Bans deleted", + "flag": "c", + "format": "i", + "value": 6 + }, + "MAIN.bans_tested": { + "description": "Bans tested against objects (lookup)", + "flag": "c", + "format": "i", + "value": 9 + }, + "MAIN.bans_obj_killed": { + "description": "Objects killed by bans (lookup)", + "flag": "c", + "format": "i", + "value": 7 + }, + "MAIN.bans_lurker_tested": { + "description": "Bans tested against objects (lurker)", + "flag": "c", + "format": "i", + "value": 37 + }, + "MAIN.bans_tests_tested": { + "description": "Ban tests tested against objects (lookup)", + "flag": "c", + "format": "i", + "value": 27 + }, + "MAIN.bans_lurker_tests_tested": { + "description": "Ban tests tested against objects (lurker)", + "flag": "c", + "format": "i", + "value": 82 + }, + "MAIN.bans_lurker_obj_killed": { + "description": "Objects killed by bans (lurker)", + "flag": "c", + "format": "i", + "value": 7 + }, + "MAIN.bans_lurker_obj_killed_cutoff": { + "description": "Objects killed by bans for cutoff (lurker)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.bans_dups": { + "description": "Bans superseded by other bans", + "flag": "c", + "format": "i", + "value": 2 + }, + "MAIN.bans_lurker_contention": { + "description": "Lurker gave way for lookup", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.bans_persisted_bytes": { + "description": "Bytes used by the persisted ban lists", + "flag": "g", + "format": "B", + "value": 1626 + }, + "MAIN.bans_persisted_fragmentation": { + "description": "Extra bytes in persisted ban lists due to fragmentation", + "flag": "g", + "format": "B", + "value": 1610 + }, + "MAIN.n_purges": { + "description": "Number of purge operations executed", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.n_obj_purged": { + "description": "Number of purged objects", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.exp_mailed": { + "description": "Number of objects mailed to expiry thread", + "flag": "c", + "format": "i", + "value": 42 + }, + "MAIN.exp_received": { + "description": "Number of objects received by expiry thread", + "flag": "c", + "format": "i", + "value": 42 + }, + "MAIN.hcb_nolock": { + "description": "HCB Lookups without lock", + "flag": "c", + "format": "i", + "value": 37 + }, + "MAIN.hcb_lock": { + "description": "HCB Lookups with lock", + "flag": "c", + "format": "i", + "value": 17 + }, + "MAIN.hcb_insert": { + "description": "HCB Inserts", + "flag": "c", + "format": "i", + "value": 17 + }, + "MAIN.esi_errors": { + "description": "ESI parse errors (unlock)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.esi_warnings": { + "description": "ESI parse warnings (unlock)", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.vmods": { + "description": "Loaded VMODs", + "flag": "g", + "format": "i", + "value": 1 + }, + "MAIN.n_gzip": { + "description": "Gzip operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.n_gunzip": { + "description": "Gunzip operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "MAIN.n_test_gunzip": { + "description": "Test gunzip operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.backend.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.backend.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.backend.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 54 + }, + "LCK.backend.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.backend.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.ban.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.ban.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.ban.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 170 + }, + "LCK.ban.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.ban.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.busyobj.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 32 + }, + "LCK.busyobj.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 32 + }, + "LCK.busyobj.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 158 + }, + "LCK.busyobj.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.busyobj.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.cli.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.cli.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.cli.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 50 + }, + "LCK.cli.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.cli.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.exp.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.exp.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.exp.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 156 + }, + "LCK.exp.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.exp.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.hcb.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.hcb.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.hcb.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 25 + }, + "LCK.hcb.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.hcb.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.lru.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 2 + }, + "LCK.lru.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.lru.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 42 + }, + "LCK.lru.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.lru.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.mempool.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 5 + }, + "LCK.mempool.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.mempool.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 765 + }, + "LCK.mempool.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.mempool.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.objhdr.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 19 + }, + "LCK.objhdr.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.objhdr.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 357 + }, + "LCK.objhdr.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.objhdr.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.perpool.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 2 + }, + "LCK.perpool.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.perpool.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 413 + }, + "LCK.perpool.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.perpool.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.pipestat.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.pipestat.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.pipestat.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.pipestat.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.pipestat.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.probe.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.probe.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.probe.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.probe.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.probe.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.sess.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 43 + }, + "LCK.sess.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 43 + }, + "LCK.sess.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 95 + }, + "LCK.sess.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.sess.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.tcp_pool.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 2 + }, + "LCK.tcp_pool.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.tcp_pool.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 106 + }, + "LCK.tcp_pool.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.tcp_pool.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vbe.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.vbe.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vbe.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 41 + }, + "LCK.vbe.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vbe.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vcapace.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.vcapace.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vcapace.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vcapace.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vcapace.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vcl.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.vcl.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vcl.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 60 + }, + "LCK.vcl.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vcl.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vxid.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.vxid.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vxid.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 3 + }, + "LCK.vxid.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.vxid.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.waiter.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 2 + }, + "LCK.waiter.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.waiter.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 107 + }, + "LCK.waiter.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.waiter.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.wq.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.wq.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.wq.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 315 + }, + "LCK.wq.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.wq.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.wstat.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 1 + }, + "LCK.wstat.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.wstat.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 117 + }, + "LCK.wstat.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.wstat.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.busyobj.live": { + "description": "In use", + "flag": "g", + "format": "i", + "value": 0 + }, + "MEMPOOL.busyobj.pool": { + "description": "In Pool", + "flag": "g", + "format": "i", + "value": 10 + }, + "MEMPOOL.busyobj.sz_wanted": { + "description": "Size requested", + "flag": "g", + "format": "B", + "value": 65536 + }, + "MEMPOOL.busyobj.sz_actual": { + "description": "Size allocated", + "flag": "g", + "format": "B", + "value": 65504 + }, + "MEMPOOL.busyobj.allocs": { + "description": "Allocations", + "flag": "c", + "format": "i", + "value": 26 + }, + "MEMPOOL.busyobj.frees": { + "description": "Frees", + "flag": "c", + "format": "i", + "value": 26 + }, + "MEMPOOL.busyobj.recycle": { + "description": "Recycled from pool", + "flag": "c", + "format": "i", + "value": 26 + }, + "MEMPOOL.busyobj.timeout": { + "description": "Timed out from pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.busyobj.toosmall": { + "description": "Too small to recycle", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.busyobj.surplus": { + "description": "Too many for pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.busyobj.randry": { + "description": "Pool ran dry", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.req0.live": { + "description": "In use", + "flag": "g", + "format": "i", + "value": 0 + }, + "MEMPOOL.req0.pool": { + "description": "In Pool", + "flag": "g", + "format": "i", + "value": 10 + }, + "MEMPOOL.req0.sz_wanted": { + "description": "Size requested", + "flag": "g", + "format": "B", + "value": 65536 + }, + "MEMPOOL.req0.sz_actual": { + "description": "Size allocated", + "flag": "g", + "format": "B", + "value": 65504 + }, + "MEMPOOL.req0.allocs": { + "description": "Allocations", + "flag": "c", + "format": "i", + "value": 21 + }, + "MEMPOOL.req0.frees": { + "description": "Frees", + "flag": "c", + "format": "i", + "value": 21 + }, + "MEMPOOL.req0.recycle": { + "description": "Recycled from pool", + "flag": "c", + "format": "i", + "value": 21 + }, + "MEMPOOL.req0.timeout": { + "description": "Timed out from pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.req0.toosmall": { + "description": "Too small to recycle", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.req0.surplus": { + "description": "Too many for pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.req0.randry": { + "description": "Pool ran dry", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess0.live": { + "description": "In use", + "flag": "g", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess0.pool": { + "description": "In Pool", + "flag": "g", + "format": "i", + "value": 10 + }, + "MEMPOOL.sess0.sz_wanted": { + "description": "Size requested", + "flag": "g", + "format": "B", + "value": 768 + }, + "MEMPOOL.sess0.sz_actual": { + "description": "Size allocated", + "flag": "g", + "format": "B", + "value": 736 + }, + "MEMPOOL.sess0.allocs": { + "description": "Allocations", + "flag": "c", + "format": "i", + "value": 21 + }, + "MEMPOOL.sess0.frees": { + "description": "Frees", + "flag": "c", + "format": "i", + "value": 21 + }, + "MEMPOOL.sess0.recycle": { + "description": "Recycled from pool", + "flag": "c", + "format": "i", + "value": 21 + }, + "MEMPOOL.sess0.timeout": { + "description": "Timed out from pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess0.toosmall": { + "description": "Too small to recycle", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess0.surplus": { + "description": "Too many for pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess0.randry": { + "description": "Pool ran dry", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.sma.creat": { + "description": "Created locks", + "flag": "c", + "format": "i", + "value": 2 + }, + "LCK.sma.destroy": { + "description": "Destroyed locks", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.sma.locks": { + "description": "Lock Operations", + "flag": "c", + "format": "i", + "value": 100 + }, + "LCK.sma.dbg_busy": { + "description": "Contended lock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "LCK.sma.dbg_try_fail": { + "description": "Contended trylock operations", + "flag": "c", + "format": "i", + "value": 0 + }, + "SMA.s0.c_req": { + "description": "Allocator requests", + "flag": "c", + "format": "i", + "value": 42 + }, + "SMA.s0.c_fail": { + "description": "Allocator failures", + "flag": "c", + "format": "i", + "value": 0 + }, + "SMA.s0.c_bytes": { + "description": "Bytes allocated", + "flag": "c", + "format": "B", + "value": 6059 + }, + "SMA.s0.c_freed": { + "description": "Bytes freed", + "flag": "c", + "format": "B", + "value": 3969 + }, + "SMA.s0.g_alloc": { + "description": "Allocations outstanding", + "flag": "g", + "format": "i", + "value": 16 + }, + "SMA.s0.g_bytes": { + "description": "Bytes outstanding", + "flag": "g", + "format": "B", + "value": 2090 + }, + "SMA.s0.g_space": { + "description": "Bytes available", + "flag": "g", + "format": "B", + "value": 67106774 + }, + "SMA.Transient.c_req": { + "description": "Allocator requests", + "flag": "c", + "format": "i", + "value": 17 + }, + "SMA.Transient.c_fail": { + "description": "Allocator failures", + "flag": "c", + "format": "i", + "value": 0 + }, + "SMA.Transient.c_bytes": { + "description": "Bytes allocated", + "flag": "c", + "format": "B", + "value": 8021 + }, + "SMA.Transient.c_freed": { + "description": "Bytes freed", + "flag": "c", + "format": "B", + "value": 7621 + }, + "SMA.Transient.g_alloc": { + "description": "Allocations outstanding", + "flag": "g", + "format": "i", + "value": 2 + }, + "SMA.Transient.g_bytes": { + "description": "Bytes outstanding", + "flag": "g", + "format": "B", + "value": 400 + }, + "SMA.Transient.g_space": { + "description": "Bytes available", + "flag": "g", + "format": "B", + "value": 0 + }, + "VBE.boot.default.happy": { + "description": "Happy health probes", + "flag": "b", + "format": "b", + "value": 0 + }, + "VBE.boot.default.bereq_hdrbytes": { + "description": "Request header bytes", + "flag": "c", + "format": "B", + "value": 6901 + }, + "VBE.boot.default.bereq_bodybytes": { + "description": "Request body bytes", + "flag": "c", + "format": "B", + "value": 0 + }, + "VBE.boot.default.beresp_hdrbytes": { + "description": "Response header bytes", + "flag": "c", + "format": "B", + "value": 5637 + }, + "VBE.boot.default.beresp_bodybytes": { + "description": "Response body bytes", + "flag": "c", + "format": "B", + "value": 44 + }, + "VBE.boot.default.pipe_hdrbytes": { + "description": "Pipe request header bytes", + "flag": "c", + "format": "B", + "value": 0 + }, + "VBE.boot.default.pipe_out": { + "description": "Piped bytes to backend", + "flag": "c", + "format": "B", + "value": 0 + }, + "VBE.boot.default.pipe_in": { + "description": "Piped bytes from backend", + "flag": "c", + "format": "B", + "value": 0 + }, + "VBE.boot.default.conn": { + "description": "Concurrent connections used", + "flag": "g", + "format": "i", + "value": 0 + }, + "VBE.boot.default.req": { + "description": "Backend requests sent", + "flag": "c", + "format": "i", + "value": 27 + }, + "VBE.boot.default.unhealthy": { + "description": "Fetches not attempted due to backend being unhealthy", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.busy": { + "description": "Fetches not attempted due to backend being busy", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.fail": { + "description": "Connections failed", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.fail_eacces": { + "description": "Connections failed with EACCES or EPERM", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.fail_eaddrnotavail": { + "description": "Connections failed with EADDRNOTAVAIL", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.fail_econnrefused": { + "description": "Connections failed with ECONNREFUSED", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.fail_enetunreach": { + "description": "Connections failed with ENETUNREACH", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.fail_etimedout": { + "description": "Connections failed ETIMEDOUT", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.fail_other": { + "description": "Connections failed for other reason", + "flag": "c", + "format": "i", + "value": 0 + }, + "VBE.boot.default.helddown": { + "description": "Connection opens not attempted", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.req1.live": { + "description": "In use", + "flag": "g", + "format": "i", + "value": 0 + }, + "MEMPOOL.req1.pool": { + "description": "In Pool", + "flag": "g", + "format": "i", + "value": 10 + }, + "MEMPOOL.req1.sz_wanted": { + "description": "Size requested", + "flag": "g", + "format": "B", + "value": 65536 + }, + "MEMPOOL.req1.sz_actual": { + "description": "Size allocated", + "flag": "g", + "format": "B", + "value": 65504 + }, + "MEMPOOL.req1.allocs": { + "description": "Allocations", + "flag": "c", + "format": "i", + "value": 22 + }, + "MEMPOOL.req1.frees": { + "description": "Frees", + "flag": "c", + "format": "i", + "value": 22 + }, + "MEMPOOL.req1.recycle": { + "description": "Recycled from pool", + "flag": "c", + "format": "i", + "value": 22 + }, + "MEMPOOL.req1.timeout": { + "description": "Timed out from pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.req1.toosmall": { + "description": "Too small to recycle", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.req1.surplus": { + "description": "Too many for pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.req1.randry": { + "description": "Pool ran dry", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess1.live": { + "description": "In use", + "flag": "g", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess1.pool": { + "description": "In Pool", + "flag": "g", + "format": "i", + "value": 10 + }, + "MEMPOOL.sess1.sz_wanted": { + "description": "Size requested", + "flag": "g", + "format": "B", + "value": 768 + }, + "MEMPOOL.sess1.sz_actual": { + "description": "Size allocated", + "flag": "g", + "format": "B", + "value": 736 + }, + "MEMPOOL.sess1.allocs": { + "description": "Allocations", + "flag": "c", + "format": "i", + "value": 22 + }, + "MEMPOOL.sess1.frees": { + "description": "Frees", + "flag": "c", + "format": "i", + "value": 22 + }, + "MEMPOOL.sess1.recycle": { + "description": "Recycled from pool", + "flag": "c", + "format": "i", + "value": 22 + }, + "MEMPOOL.sess1.timeout": { + "description": "Timed out from pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess1.toosmall": { + "description": "Too small to recycle", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess1.surplus": { + "description": "Too many for pool", + "flag": "c", + "format": "i", + "value": 0 + }, + "MEMPOOL.sess1.randry": { + "description": "Pool ran dry", + "flag": "c", + "format": "i", + "value": 0 + } + } +} diff --git a/varnish.go b/varnish.go index e400467..527464e 100644 --- a/varnish.go +++ b/varnish.go @@ -68,14 +68,18 @@ func ScrapeVarnishFrom(buf []byte, ch chan<- prometheus.Metric) ([]byte, error) } countersJSON := make(map[string]interface{}) - if metricsJSON["version"] == 1 { - countersJSON = metricsJSON["counters"] + if version, ok := metricsJSON["version"]; ok { + if version.(json.Number) == "1" { + countersJSON = metricsJSON["counters"].(map[string]interface{}) + } else { + return nil, fmt.Errorf("unknown stats json version: %#v", version) + } } else { countersJSON = metricsJSON } for vName, raw := range countersJSON { - if vName == "version" || vName == "timestamp" { + if vName == "timestamp" { continue } if dt := reflect.TypeOf(raw); dt.Kind() != reflect.Map { diff --git a/varnish_test.go b/varnish_test.go index c2e40af..99e07b8 100644 --- a/varnish_test.go +++ b/varnish_test.go @@ -11,10 +11,13 @@ import ( "github.com/prometheus/client_golang/prometheus" ) -var testFileVersions = []string{"3.0.5", "4.0.5", "4.1.1", "5.2.0", "6.0.0"} +var testFileVersions = []string{"3.0.5", "4.0.5", "4.1.1", "5.2.0", "6.0.0", "6.5.1"} func Test_VarnishVersion(t *testing.T) { tests := map[string]*varnishVersion{ + "varnishstat (varnish-6.5.1 revision 1dae23376bb5ea7a6b8e9e4b9ed95cdc9469fb64)": &varnishVersion{ + Major: 6, Minor: 5, Patch: 1, Revision: "1dae23376bb5ea7a6b8e9e4b9ed95cdc9469fb64", + }, "varnishstat (varnish-6.0.0 revision a068361dff0d25a0d85cf82a6e5fdaf315e06a7d)": &varnishVersion{ Major: 6, Minor: 0, Patch: 0, Revision: "a068361dff0d25a0d85cf82a6e5fdaf315e06a7d", }, @@ -92,11 +95,11 @@ func matchStringSlices(s1, s2 []string) bool { func Test_VarnishBackendNames(t *testing.T) { for _, variant := range [][]string{ {"eu1_x.y-z:w(192.52.0.192,,8085)", "eu1_x.y-z:w", "192.52.0.192,,8085"}, // 4.0.3 - {"root:eu2_x.y-z:w", "eu2_x.y-z:w", "unknown"}, // 4.1 + {"root:eu2_x.y-z:w", "eu2_x.y-z:w", "unknown"}, // 4.1 {"def0e7f7-a676-4eed-9d8b-78ef7ce21e93.us1_x.y-z:w", "us1_x.y-z:w", "def0e7f7-a676-4eed-9d8b-78ef7ce21e93"}, {"root:29813cbb-7329-4eb8-8969-26be2ef58c88.us2_x.y-z:w", "us2_x.y-z:w", "29813cbb-7329-4eb8-8969-26be2ef58c88"}, // ?? {"boot.default", "default", "unknown"}, - {"reload_2019-08-29T100458.default", "default", "unknown"}, // varnish_reload_vcl in 4 + {"reload_2019-08-29T100458.default", "default", "unknown"}, // varnish_reload_vcl in 4 {"reload_20191016_072034_54500.default", "default", "unknown"}, // varnishreload in 6+ {"ce19737f-72b5-4f4b-9d39-3d8c2d28240b.default", "default", "ce19737f-72b5-4f4b-9d39-3d8c2d28240b"}, } { @@ -220,7 +223,7 @@ func Test_PrometheusExport(t *testing.T) { t.Logf("test scrape %s", VarnishVersion) registry := prometheus.NewRegistry() - collector := &testCollector{filepath: test} + collector := &testCollector{filepath: test, t: t} registry.MustRegister(collector) gathering, err := registry.Gather() @@ -237,10 +240,20 @@ func Test_PrometheusExport(t *testing.T) { metricCount := 0 + includesVarnishBackendHappy := false for _, mf := range gathering { + if *mf.Name == "varnish_backend_happy" { + includesVarnishBackendHappy = true + } + metricCount += len(mf.Metric) } + // Validate presence of a single metric, which is present across all versions + if !includesVarnishBackendHappy { + t.Error(" Missing metric varnish_backend_happy") + } + t.Logf(" %d metrics", metricCount) } }