Skip to content

Observability

This page covers the signals available from a running Varnish Gateway: health endpoints, Prometheus metrics, the built-in dashboard, and log access.

Health endpoints

Chaperone exposes HTTP endpoints on the health address. In operator-managed pods this is port 8081 (the operator sets HEALTH_ADDR=:8081 and points the readiness probe at it); standalone chaperone falls back to :8080 if the variable is unset.

Path Method Description
/health GET Returns 200 when the pod is ready, 503 when not ready or draining.
/drain GET Initiates graceful shutdown. The pod stops accepting new connections.
/debug/backends GET Exposes varnishadm backend.list output. Accepts format=json and detailed=true query parameters.
/metrics GET Prometheus metrics endpoint.

The /health endpoint is used by the Kubernetes readiness probe. A pod becomes ready after the initial VCL load and the first ghost reload both complete. On SIGTERM the pod enters draining state and /health returns 503, giving the Service time to remove the pod from the endpoint list before connections close.

Prometheus metrics

Chaperone metrics

Chaperone registers its own metrics on the /metrics endpoint alongside Go runtime and process collectors.

Counters

Metric Description
chaperone_ghost_reloads_total Ghost reload attempts
chaperone_ghost_reload_errors_total Failed ghost reloads
chaperone_vcl_reloads_total VCL hot-reload attempts
chaperone_vcl_reload_errors_total Failed VCL reloads
chaperone_tls_reloads_total TLS certificate reload attempts
chaperone_tls_reload_errors_total Failed TLS reloads
chaperone_endpoint_changes_total EndpointSlice change events

Gauges

Metric Description
chaperone_ready 1 when the pod is ready, 0 otherwise
chaperone_draining 1 when the pod is draining

Route VCL metrics

Registered on every chaperone, also when route VCL is off (the series then stay at zero). Route VCL loads are not counted in chaperone_vcl_reloads_total; that counter and its error counterpart cover the master VCL only.

Metric Type Labels Description
chaperone_route_vcl_compiles_total counter result (ok, compile_error, error) Route VCL loads. ok = compiled (or already loaded) and labelled; compile_error = VCC rejected the document; error = any other refusal or a failed vcl.label
chaperone_route_vcl_compile_duration_seconds histogram - Duration of route VCL vcl.inline calls, 0.05 s to 5 s buckets. Includes failed compiles
chaperone_route_vcl_slots gauge state (programmed, failed, placeholder) Pool slots by state on this pod. failed = compile failed or waiting for a master; the slot serves its previous VCL or the placeholder. placeholder = empty slots
chaperone_route_vcl_master_reloads_total counter result (ok, error) Master VCL loads (the VCL that dispatches to route VCLs). Also counted in chaperone_vcl_reloads_total

The slot gauges are updated after each slot pass that changed something. A sustained failed > 0 means a policy is Programmed=False; check kubectl get vvp. A high compile_error rate with a flat slot count means a document is being retried; failed documents are remembered for five minutes, so this should not climb quickly.

The operator exports varnish_gateway_route_vcl_slots, varnish_gateway_route_vcl_unassigned and varnish_gateway_route_vcl_policies{programmed="true|false"}, see Operator metrics.

Jumps per second are not exported. Ghost's per-vhost counters are not VSC counters (they exist only in the backend.list JSON), so there is no route_vcl_dispatch counter in varnishstat. To see dispatch activity, use varnishlog -q 'VCL_use ~ via': a jump logs a VCL_use record naming the label and the VCL it came from. MAIN.n_vcl and MAIN.n_vcl_avail show how many VCLs are loaded.

Varnish metrics

Chaperone runs varnishstat -1 -j periodically and exposes each counter as a Prometheus metric. Counter names are lowercased with dots replaced by underscores — for example, MAIN.cache_hit becomes varnish_main_cache_hit. Varnishstat counters flagged as cumulative are exposed as Prometheus counters; all others as gauges.

Operator metrics

The operator exposes metrics on its own metrics address, port 8080 by default. These fall into three groups.

Controller-runtime and client-go metrics — reconciliation latency, work queue depth, error counts, and Kubernetes API request latency (controller_runtime_*, workqueue_*, rest_client_*). These are the standard control-plane metrics documented upstream.

Gateway API inventory and status metrics — domain metrics describing the Gateway API objects the operator manages. Only objects belonging to a GatewayClass with our controller name are counted.

Gauges

Metric Labels Description
varnish_gateway_gateways gatewayclass Number of managed Gateways, by GatewayClass
varnish_gateway_gateway_accepted gateway_namespace, gateway_name 1 when the Gateway's Accepted condition is true, 0 otherwise
varnish_gateway_gateway_programmed gateway_namespace, gateway_name 1 when the Gateway's Programmed condition is true, 0 otherwise
varnish_gateway_gateway_listeners gateway_namespace, gateway_name Number of listeners configured on the Gateway
varnish_gateway_gateway_attached_routes gateway_namespace, gateway_name Total AttachedRoutes across all listeners of the Gateway
varnish_gateway_httproutes — Number of HTTPRoutes attached to a managed Gateway
varnish_gateway_httproutes_accepted — Number of managed HTTPRoutes Accepted on at least one parent
varnish_gateway_route_vcl_slots gateway_namespace, gateway_name, state (used/released/free) Route VCL slots of the Gateway: holding a VarnishVCLPolicy, in quarantine after their policy left, or free. All 0 when route VCL is off
varnish_gateway_route_vcl_unassigned gateway_namespace, gateway_name Eligible VarnishVCLPolicies that got no slot (pool exhausted, pool shrunk, ConfigMap full)
varnish_gateway_route_vcl_policies programmed (true/false) VarnishVCLPolicies by Programmed condition (anything but True counts as false). Absent when the VarnishVCLPolicy CRD is not installed
varnish_gateway_info version Constant 1; carries the operator build version as a label

The per-Gateway labels are gateway_namespace / gateway_name rather than namespace / name on purpose: Prometheus (and the prometheus-operator ServiceMonitor) attach a namespace label for the operator's own pod at scrape time, which would otherwise collide with and mask the Gateway object's namespace.

These are snapshotted from the controller cache at scrape time, so a deleted Gateway or HTTPRoute drops out of the metrics on the next scrape rather than lingering as a stale series. An HTTPRoute is counted only when one of its parentRefs resolves to a Gateway this operator actually manages — routes pointing at a non-existent or foreign Gateway are not counted. HTTPRoutes are reported as aggregate counts (not per-route series) to keep cardinality bounded on clusters with many routes.

Prometheus scraping

The Helm chart can create ServiceMonitor (operator) and PodMonitor (chaperone) resources for auto-discovery by the prometheus-operator. This requires the monitoring.coreos.com CRDs to be installed — for example, via kube-prometheus-stack.

# values.yaml
serviceMonitor:
  enabled: true
  interval: 30s
  scrapeTimeout: 10s
  # Match your Prometheus instance's serviceMonitorSelector / podMonitorSelector.
  # For kube-prometheus-stack the default selector is `release: <helm-release>`.
  labels:
    release: kube-prometheus-stack

The operator metrics Service ({release}-varnish-gateway-operator-metrics) is created unconditionally so you can port-forward it without enabling the monitor objects.

The chaperone PodMonitor selects all Gateway pods across namespaces by the app.kubernetes.io/managed-by: varnish-gateway-operator label, so a single monitor covers every Gateway the operator manages.

Grafana dashboards

The chart ships four Grafana dashboards under charts/varnish-gateway/dashboards/:

Dashboard UID Focus
Varnish varnish-gateway-varnish Client rate, hit ratio, backend errors, threads, storage, bans
Chaperone varnish-gateway-chaperone Ready/draining state, reload rates and errors, endpoint churn
Operator varnish-gateway-operator Reconcile latency, workqueue queue/work duration, client-go codes
Soak — Resources varnish-gateway-soak-resources Heap, RSS, goroutines, FDs, GC, CPU, restarts — side-by-side leak detector

The Varnish and Chaperone dashboards target day-to-day operations; the Operator and Soak dashboards target regression detection during soak tests and upgrades.

Two packaging options:

Helm (auto-discovery via the Grafana sidecar). Set dashboards.enabled=true. Each JSON file becomes a ConfigMap carrying the grafana_dashboard: "1" label, which kube-prometheus-stack's Grafana sidecar watches by default:

# values.yaml
dashboards:
  enabled: true
  # Optional folder hint for grafana-operator-style sidecars.
  # annotations:
  #   grafana_folder: Varnish Gateway

Manual import. Open Grafana → Dashboards → Import → paste the JSON from charts/varnish-gateway/dashboards/*.json.

Dashboards target Grafana v12 (schemaVersion: 41).

Dashboard

Chaperone includes an embedded dashboard, enabled by default on port 9000 inside the container. It is not exposed outside the pod via the Service, but you can reach it with kubectl port-forward:

kubectl port-forward <gateway-pod> 9000:9000

Then open http://localhost:9000 in a browser.

When route VCL is on, the page has a Route VCL section: pool size, the active master VCL, and one row per populated slot with its policy, route, loaded VCL name, state (programmed or compile failed) and the compiler error.

The dashboard exposes:

Path Description
/ HTML dashboard UI
/api/state JSON snapshot: ready/draining state, uptime, vhosts, services, route VCL slots (routeVcl), recent events
/api/events Server-Sent Events stream of reload, endpoint, and state-change events
/api/varnishlog Server-Sent Events stream of live varnishlog-json output, with query parameter filtering

The /api/varnishlog endpoint accepts query parameters for filtering:

Parameter Description
q VSL query filter
g Grouping: request, vxid, session, raw
R Rate limit, e.g. 10/s
mode b for backend only, c for client only, empty for both
i Include tags, comma-separated
x Exclude tags

There is a limit of two concurrent varnishlog sessions per pod.

Logs

Operator logs

The operator writes structured logs to stdout via log/slog:

kubectl logs -n varnish-gateway-system -l app.kubernetes.io/component=operator -f

Chaperone logs

Chaperone also writes structured logs to stdout. These cover varnishd lifecycle events, reload successes and failures, and endpoint changes:

kubectl logs -f <gateway-pod> -c varnish-gateway

Varnish request logs

Varnish request logs are not emitted by default. There are three ways to access them:

Logging sidecar — enable spec.logging on your GatewayClassParameters to run a sidecar that streams varnishlog, varnishlog-json, or varnishncsa to stdout. See guides/logging.md for configuration and examples.

kubectl logs -f <gateway-pod> -c varnish-log

kubectl exec — for ad-hoc debugging, run varnishlog directly inside the chaperone container:

kubectl exec -it <gateway-pod> -c varnish-gateway -- \
  varnishlog -n /var/run/varnish/vsm -g request

Dashboard — if the dashboard is enabled, the /api/varnishlog endpoint streams filtered varnishlog-json output over Server-Sent Events.

See also