kgateway
The built-in kgateway system type for the gateway proxy - why it is picked by hand, getting traces and metrics from a ListenerPolicy and the proxy's own endpoint, what Envoy's response flags say about a failure, and per-route checks that do not drag every integration down.
kgateway is a CNCF implementation of the Kubernetes Gateway API, built on Envoy. Each Gateway resource becomes a fleet of Envoy proxies that route your traffic, configured by kgateway’s control plane. This type watches the proxy: the service in the traffic path, which is what your integrations go through.
Key: kgateway · picked by hand on the gateway’s service. It does not apply automatically, for the reason below.
Two processes, two types
Section titled “Two processes, two types”A kgateway installation is two kinds of process, and they emit telemetry that does not overlap:
| Process | Emits | Type |
|---|---|---|
| gateway proxy (one Deployment per Gateway) | Envoy traces, envoy_* metrics | kgateway (this page) |
control plane (the kgateway Deployment) | kgateway_* metrics | kgateway-controller |
A check belongs where its metric exists, so each process has its own type. Apply each to its own service. The most important control plane check, a gateway that rejected its configuration and silently stopped taking route changes, lives on the other type.
Why it is picked by hand
Section titled “Why it is picked by hand”The proxy is plain Envoy. Its metrics are Envoy’s, its spans are Envoy’s, and nothing in either names kgateway. Recognising it from envoy_ would offer “kgateway” to every Istio gateway, Envoy Gateway and Contour proxy as well. So on the gateway’s service, tick Mark as a system and pick kgateway as its type, once. Its checks are then offered like any other type’s.
Getting the telemetry
Section titled “Getting the telemetry”Traces (and access logs)
Section titled “Traces (and access logs)”Point the gateway at a Collector with a ListenerPolicy. kgateway names the proxy’s service <gateway>.<namespace> (for example http.kgateway-system) and adds service.version and the Kubernetes resource attributes on its own.
apiVersion: gateway.kgateway.dev/v1alpha1kind: ListenerPolicymetadata: name: otel namespace: kgateway-systemspec: targetRefs: - group: gateway.networking.k8s.io kind: Gateway name: http default: httpSettings: tracing: provider: openTelemetry: grpcService: backendRef: { name: otel-collector, namespace: kgateway-system, port: 4317 } # Optional: access logs over OTLP, correlated with the trace. accessLog: - openTelemetry: grpcService: backendRef: { name: otel-collector, namespace: kgateway-system, port: 4317 } logName: http-gateway-access-log body: '"%REQ(:METHOD)% %REQ(:PATH)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %UPSTREAM_CLUSTER%'ListenerPolicy replaced HTTPListenerPolicy in kgateway 2.5.
Metrics
Section titled “Metrics”The proxy does not push metrics. Its pods are annotated for scraping (/metrics on port 9091), and so is the control plane (port 9092). One scrape job covers both. The two job rules matter: the receiver turns job into service.name, and these give the proxy the same name its traces carry, so a gateway’s metrics and traces are one service in Sluicio. The control plane becomes kgateway.
receivers: prometheus/kgateway: config: scrape_configs: - job_name: kgateway scrape_interval: 30s kubernetes_sd_configs: [{ role: pod }] relabel_configs: # kgateway's own pods: the controller and every gateway proxy. - source_labels: [__meta_kubernetes_pod_label_kgateway] regex: kgateway|kube-gateway action: keep - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape] regex: "true" action: keep - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port] regex: ([^:]+)(?::\d+)?;(\d+) replacement: $$1:$$2 target_label: __address__ - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path] regex: (.+) target_label: __metrics_path__ # service.name: "kgateway" for the controller, # <gateway>.<namespace> for a proxy, matching its traces. - source_labels: [__meta_kubernetes_pod_label_app_kubernetes_io_name] target_label: job - source_labels: [__meta_kubernetes_pod_label_gateway_networking_k8s_io_gateway_name, __meta_kubernetes_namespace] regex: (.+);(.+) replacement: $$1.$$2 target_label: job$$ is how a literal $ is written in a Collector configuration. Pod discovery needs a ClusterRole that can get, list and watch pods for the Collector’s service account.
What the proxy says about a failure
Section titled “What the proxy says about a failure”Envoy marks a span failed when the response is a 5xx and leaves a 4xx alone, so no “Treat HTTP 5xx as errors” setting is needed. Each span also carries response_flags, which says whether the gateway itself was the reason. What kgateway 2.5 produced for each kind of fault:
| What happened | Response | response_flags | Span failed |
|---|---|---|---|
| The backend answered 503 | 503 | - | yes |
| The route’s backend does not exist | 500 | NC | yes |
| The backend Service has no ready pods | 503 | UH | yes |
| The backend refused the connection | 503 | UF | yes |
| The route’s timeout ran out | 504 | UT | yes |
| No route matches the host or path | 404 | NR | no |
Each span also names the URL (http.url) and, when a backend was chosen, upstream_cluster, which kgateway names kube_<namespace>_<service>_<port>.
Starter checks
Section titled “Starter checks”| Check | Condition | Severity | Scope |
|---|---|---|---|
| Requests failing | ≥ 1 failed span in 5 minutes | Warning | per route |
| Route points at a missing backend | ≥ 1 failed span with response_flags NC in 5 minutes | Warning | per route |
| No healthy backend | envoy_cluster_upstream_cx_none_healthy rising, split by envoy_cluster_name | Warning | per route |
| Backend refusing connections | envoy_cluster_upstream_cx_connect_fail rising, split by envoy_cluster_name | Warning | per route |
| Backend timeouts | envoy_cluster_upstream_rq_timeout rising, split by envoy_cluster_name | Warning | per route |
| Slow requests | p95 ≥ 2000 ms over 5 minutes | Warning | per route |
| Gateway silent | no requests in 15 minutes | Warning | whole gateway |
| Proxy lost the control plane | envoy_control_plane_connected_state < 1 | Warning | whole gateway |
| Gateway proxy not running | envoy_server_live stops arriving | Critical | whole gateway |
A missing backend is only visible in the trace. kgateway accepts a route whose backendRef names a Service that does not exist (its status says ResolvedRefs: False), and the gateway answers 500 without contacting anything. No Envoy cluster is involved, so none of the backend counters move.
Losing the control plane does not stop traffic. The proxy keeps serving its last configuration, which is why nothing else would notice. What stops is change: a new route or policy does not arrive until the proxy reconnects.
One gateway, many integrations
Section titled “One gateway, many integrations”A gateway is shared: it routes for every integration behind it. The per-route checks above are declared as describing one flow, so a failing backend does not mark every integration on the gateway unhealthy. The whole-gateway checks are left unsplit on purpose, so they do reach every integration: a proxy that is down breaks all of them.
To alert on one route alone, make it an integration: match the gateway’s service and a condition on http.url (or upstream_cluster), and bind checks to that.
Tuning notes
Section titled “Tuning notes”- Backend counters appear when first used. The proxy’s
/metricsis Envoy’s “used only” view, soenvoy_cluster_upstream_rq_timeoutdoes not exist until a timeout happens. A check reads the rise within its window, so a backend’s very first failures since the proxy started are counted from the next scrape on. Scraping/stats/prometheuson the admin port instead lists every counter from zero, at about four times the series. - Sampling thins the trace checks, not the metrics. With
randomSamplingbelow 100 in theListenerPolicy, the span-based checks see a sample. Lower their thresholds accordingly, or rely on the backend counters, which count every request. - No check on unmatched requests. A 404 with
NRis what a scanner probing random hosts produces all day on a public gateway, so it is not an alert by default. On an internal gateway it can mean a route that never took effect; see Gateway rejected its configuration. - Slow requests depends on what is behind the gateway. 2000 ms is a stuck UI call and a quick report export.