TrustGate provides comprehensive monitoring capabilities through a Prometheus metrics endpoint. This guide explains how to access and interpret these metrics to monitor your gateway’s performance and health.
Configuration
Metrics collection can be configured in your TrustGate configuration file:
server:
admin_port: 8080
metrics_port: 9090 # Port where metrics are exposed
proxy_port: 8081
base_domain: example.com
metrics:
enabled: true # Enable/disable all metrics
enable_latency: true # Basic latency metrics
enable_upstream: true # Upstream latency (high cardinality)
enable_connections: true # Connection tracking
enable_per_route: true # Per-route metrics (high cardinality)
enable_detailed_status: true # Detailed status codes
TrustGate exposes metrics at the /metrics
endpoint in Prometheus format. These metrics provide insights into request processing, latency, connections, and overall system health.
Connection Metrics
# HELP trustgate_connections Number of active connections
# TYPE trustgate_connections gauge
This gauge metric tracks the number of active connections to your gateway. It includes the following labels:
gateway_id
: Unique identifier for the gateway instance
state
: Connection state (e.g., “active”)
Request Metrics
# HELP trustgate_requests_total Total number of requests processed
# TYPE trustgate_requests_total counter
This counter tracks the total number of requests processed by the gateway with labels for:
gateway_id
: Gateway instance identifier
method
: HTTP method (GET, POST, etc.)
status
: HTTP status code category (2xx, 4xx, 5xx)
Latency Metrics
TrustGate provides three types of latency histograms:
- Overall Request Latency
# HELP trustgate_latency_ms Request latency in milliseconds
# TYPE trustgate_latency_ms histogram
- Detailed Route/Service Latency
# HELP trustgate_detailed_latency_ms Detailed request latency by service and route
# TYPE trustgate_detailed_latency_ms histogram
- Upstream Service Latency
# HELP trustgate_upstream_latency_ms Upstream service latency in milliseconds
# TYPE trustgate_upstream_latency_ms histogram
All latency metrics include bucket ranges from 5ms to 30s and provide:
gateway_id
: Gateway instance identifier
route
: Route ID (for detailed and upstream metrics)
service
: Service ID (for detailed and upstream metrics)
type
: Request path (for overall latency)
Prometheus Handler Metrics
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served
# TYPE promhttp_metric_handler_requests_in_flight gauge
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code
# TYPE promhttp_metric_handler_requests_total counter
These metrics provide information about the Prometheus metrics endpoint itself.
Responses are generated using AI and may contain mistakes.