TUN-1732: cloudflared metrics should track userHostnames

This commit is contained in:
Adam Chalmers 2019-04-16 15:26:31 -05:00
parent 2bef5dbe72
commit 2e2fa29637
2 changed files with 15 additions and 2 deletions

View File

@ -57,6 +57,7 @@ type TunnelMetrics struct {
muxerMetrics *muxerMetrics muxerMetrics *muxerMetrics
tunnelsHA tunnelsForHA tunnelsHA tunnelsForHA
userHostnamesCounts *prometheus.CounterVec
} }
func newMuxerMetrics() *muxerMetrics { func newMuxerMetrics() *muxerMetrics {
@ -364,6 +365,15 @@ func NewTunnelMetrics() *TunnelMetrics {
) )
prometheus.MustRegister(registerFail) prometheus.MustRegister(registerFail)
userHostnamesCounts := prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "user_hostnames_counts",
Help: "Which user hostnames cloudflared is serving",
},
[]string{"userHostname"},
)
prometheus.MustRegister(userHostnamesCounts)
registerSuccess := prometheus.NewCounter( registerSuccess := prometheus.NewCounter(
prometheus.CounterOpts{ prometheus.CounterOpts{
Name: "tunnel_register_success", Name: "tunnel_register_success",
@ -389,6 +399,7 @@ func NewTunnelMetrics() *TunnelMetrics {
regSuccess: registerSuccess, regSuccess: registerSuccess,
regFail: registerFail, regFail: registerFail,
rpcFail: rpcFail, rpcFail: rpcFail,
userHostnamesCounts: userHostnamesCounts,
} }
} }

View File

@ -396,6 +396,8 @@ func RegisterTunnel(
} }
} }
config.Metrics.userHostnamesCounts.WithLabelValues(registration.Url).Inc()
config.Logger.Infof("Route propagating, it may take up to 1 minute for your new route to become functional") config.Logger.Infof("Route propagating, it may take up to 1 minute for your new route to become functional")
return nil return nil
} }