Gateway Monitoring

Scrape Gateway metrics with Prometheus, add alerting rules, and import the Grafana dashboard.

The Gateway exposes Prometheus metrics at /metrics on port 9090.

Scrape metrics

Kubernetes

With the Prometheus Operator, enable either a PodMonitor or a ServiceMonitor in the Gateway Helm values. Add additionalLabels if your Prometheus instance selects monitors by label.

metrics:
podMonitor:
enabled: true
additionalLabels:
release: prometheus
metrics:
serviceMonitor:
enabled: true
additionalLabels:
release: prometheus

Check the Gateway targets on the Prometheus Status > Targets page.

VM

Add a static scrape target to your Prometheus configuration:

scrape_configs:
- job_name: twingate-gateway
static_configs:
- targets: ["<GATEWAY_HOST>:9090"]

Alerting rules

Kubernetes

With the Prometheus Operator installed, the Gateway Helm chart can create a PrometheusRule:

metrics:
prometheusRule:
enabled: true
rules:
- alert: TwingateGatewayHighHTTPErrorRate
expr: |
max_over_time(
(sum by (code, method, type, resource_type) (rate(twingate_gateway_http_requests_total{code=~"5[0-9][0-9]"}[5m])) > bool 0.8)[2m:30s]
) > 0
for: 2m
labels:
severity: critical
annotations:
description: Gateway HTTP {{ $labels.code }} error rate is above 0.8 requests/sec over last 2 minutes for method={{ $labels.method }}, type={{ $labels.type }}, resource_type={{ $labels.resource_type }}.

The chart’s values.yaml includes more example rules as comments.

VM

Add the same rules to a Prometheus alerting rules file under a groups entry:

groups:
- name: twingate-gateway
rules:
- alert: TwingateGatewayHighHTTPErrorRate
# same expr, for, labels, and annotations as above

Grafana dashboard

Kubernetes

Enable the dashboard in the Gateway Helm values. The chart creates a ConfigMap that the Grafana dashboard sidecar discovers:

metrics:
grafanaDashboard:
enabled: true
labels:
grafana_dashboard: "1"

If Grafana runs in a different namespace from the Gateway, configure Grafana to search that namespace. With the Grafana Helm chart, add it to sidecar.dashboards.searchNamespace.

VM

Import the dashboard JSON from the Gateway repository. In Grafana, go to Dashboards > New > Import and upload or paste the file.

Metrics reference

Core metrics

Available in every deployment.

NameTypeDescription
twingate_gateway_tcp_connection_duration_secondsHistogramDuration of client TCP connections
twingate_gateway_tcp_connections_totalCounterClient TCP connections processed
twingate_gateway_active_tcp_connectionsGaugeCurrently active client TCP connections
twingate_gateway_client_authentication_totalCounterHTTP CONNECT authentication attempts from the Twingate Client
twingate_gateway_client_connection_duration_secondsHistogramDuration of HTTP CONNECT authentication attempts
twingate_gateway_recorded_session_duration_secondsHistogramDuration of recorded sessions (Kubernetes and SSH)

Kubernetes and Web App metrics

HTTP request metrics are labeled by resource_type (kubernetes or web_app) and by type (http, websocket, spdy, or unknown).

NameTypeDescription
twingate_gateway_http_active_requestsGaugeCurrently active HTTP requests
twingate_gateway_http_request_duration_secondsHistogramHTTP request latency
twingate_gateway_http_request_size_bytesHistogramIncoming HTTP request size
twingate_gateway_http_requests_totalCounterHTTP requests processed
twingate_gateway_http_response_size_bytesHistogramOutgoing HTTP response size
twingate_gateway_api_server_active_requestsGaugeCurrently active requests from the Gateway to the upstream server (the Kubernetes API server or the web app)
twingate_gateway_api_server_request_duration_secondsHistogramRequest-response latency between the Gateway and the upstream server. For streaming, WebSocket, and SPDY connections, measures setup time only.
twingate_gateway_api_server_requests_totalCounterRequests from the Gateway to the upstream server

SSH-specific metrics are not yet available.

Runtime and scrape metrics

The Gateway also exports standard Go runtime (go_*) and process (process_*) metrics, and these scrape metrics:

NameTypeDescription
promhttp_metric_handler_errors_totalCounterInternal errors in the metrics handler
promhttp_metric_handler_requests_in_flightGaugeScrapes in progress
promhttp_metric_handler_requests_totalCounterScrapes, by HTTP status code

Last updated