You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expose prometheus metrics for the router by default
Add new settings to the router that allow metrics to be captured via
/metrics on a configurable listen address. Metrics and pprof data are
only available when stats username and password are set, and require
auth.
The metrics implementation uses a variant of prometheus/haproxy_exporter
and attempts to minimize the amount of metrics returned for the router.
It also rate limits the frequency at which the haproxy stats endpoint is
scraped relative to the amount of servers defined (a rough rule of thumb
from this data is that for every 1000 servers the minimum interval
increases by 5 seconds). The metrics returned are not transformed to be
service based, but could be.
This currently generates ~1.8M per 1k routes. Shorter server identifiers
would have an impact. This generates a ~2% CPU cost on the router
endpoint when run every 2s, which should scale reasonably to
infrastructure.
flag.BoolVar(&o.DisableNamespaceOwnershipCheck, "disable-namespace-ownership-check", cmdutil.Env("ROUTER_DISABLE_NAMESPACE_OWNERSHIP_CHECK", "") =="true", "Disables the namespace ownership checks for a route host with different paths or for overlapping host names in the case of wildcard routes. Please be aware that if namespace ownership checks are disabled, routes in a different namespace can use this mechanism to 'steal' sub-paths for existing domains. This is only safe if route creation privileges are restricted, or if all the users can be trusted.")
75
77
flag.BoolVar(&o.EnableIngress, "enable-ingress", cmdutil.Env("ROUTER_ENABLE_INGRESS", "") =="true", "Enable configuration via ingress resources")
78
+
flag.StringVar(&o.ListenAddr, "listen-addr", cmdutil.Env("ROUTER_LISTEN_ADDR", ""), "The name of an interface to listen on to expose metrics and health checking. If not specified, will not listen.")
76
79
}
77
80
78
81
// RouteSelectionFunc returns a func that identifies the host for a route.
// reloadInterval returns how often to run the router reloads. The interval
@@ -93,6 +97,7 @@ func (o *TemplateRouter) Bind(flag *pflag.FlagSet) {
93
97
flag.BoolVar(&o.ExtendedValidation, "extended-validation", util.Env("EXTENDED_VALIDATION", "true") =="true", "If set, then an additional extended validation step is performed on all routes admitted in by this router. Defaults to true and enables the extended validation checks.")
94
98
flag.BoolVar(&o.BindPortsAfterSync, "bind-ports-after-sync", util.Env("ROUTER_BIND_PORTS_AFTER_SYNC", "") =="true", "Bind ports only after route state has been synchronized")
95
99
flag.StringVar(&o.MaxConnections, "max-connections", util.Env("ROUTER_MAX_CONNECTIONS", ""), "Specifies the maximum number of concurrent connections.")
100
+
flag.StringVar(&o.MetricsType, "metrics-type", util.Env("ROUTER_METRICS_TYPE", ""), "Specifies the type of metrics to gather. Supports 'haproxy'.")
96
101
}
97
102
98
103
typeRouterStatsstruct {
@@ -178,6 +183,9 @@ func (o *TemplateRouterOptions) Complete() error {
0 commit comments