Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
feat(metrics): add proxy rejected max connections metric (#4589)
Browse files Browse the repository at this point in the history
This change adds the `osm_proxy_max_connections_rejected` metric which
counts the number of proxy connections rejected because of the limit
defined by the MeshConfig's spec.sidecar.maxDataPlaneConnections having
been reached.

Part of #4568

Signed-off-by: Jon Huhn <[email protected]>
  • Loading branch information
nojnhuh authored Mar 11, 2022
1 parent b7a4a3b commit 1775316
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/osm-controller/osm-controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func startMetricsStore() {
metricsstore.DefaultMetricsStore.HTTPResponseDuration,
metricsstore.DefaultMetricsStore.FeatureFlagEnabled,
metricsstore.DefaultMetricsStore.ProxyXDSRequestCount,
metricsstore.DefaultMetricsStore.ProxyMaxConnectionsRejected,
)
}

Expand Down
1 change: 1 addition & 0 deletions pkg/envoy/ads/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func (s *Server) StreamAggregatedResources(server xds_discovery.AggregatedDiscov

// If maxDataPlaneConnections is enabled i.e. not 0, then check that the number of Envoy connections is less than maxDataPlaneConnections
if s.cfg.GetMaxDataPlaneConnections() != 0 && s.proxyRegistry.GetConnectedProxyCount() >= s.cfg.GetMaxDataPlaneConnections() {
metricsstore.DefaultMetricsStore.ProxyMaxConnectionsRejected.Inc()
return errTooManyConnections
}

Expand Down
11 changes: 11 additions & 0 deletions pkg/metricsstore/metricsstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ type MetricsStore struct {
// ProxyXDSRequestCount counts XDS requests made by proxies
ProxyXDSRequestCount *prometheus.CounterVec

// ProxyMaxConnectionsRejected counts the number of proxy connections
// rejected due to the max connections limit being reached
ProxyMaxConnectionsRejected prometheus.Counter

/*
* Injector metrics
*/
Expand Down Expand Up @@ -181,6 +185,13 @@ func init() {
Help: "Represents the number of XDS requests made by proxies",
}, []string{"common_name", "type"})

defaultMetricsStore.ProxyMaxConnectionsRejected = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: metricsRootNamespace,
Subsystem: "proxy",
Name: "max_connections_rejected",
Help: "Represents the number of proxy connections rejected due to the configured max connections limit",
})

/*
* Injector metrics
*/
Expand Down

0 comments on commit 1775316

Please sign in to comment.