TUN-2563: Exposes config_version metrics
This commit is contained in:
parent
1ba5abfdb3
commit
c5bacf4d95
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/cloudflare/cloudflared/h2mux"
|
"github.com/cloudflare/cloudflared/h2mux"
|
||||||
"github.com/cloudflare/cloudflared/streamhandler"
|
"github.com/cloudflare/cloudflared/streamhandler"
|
||||||
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
|
"github.com/cloudflare/cloudflared/tunnelrpc/pogs"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -28,6 +29,27 @@ type Supervisor struct {
|
||||||
useConfigResultChan chan<- *pogs.UseConfigurationResult
|
useConfigResultChan chan<- *pogs.UseConfigurationResult
|
||||||
state *state
|
state *state
|
||||||
logger *logrus.Entry
|
logger *logrus.Entry
|
||||||
|
metrics metrics
|
||||||
|
}
|
||||||
|
|
||||||
|
type metrics struct {
|
||||||
|
configVersion prometheus.Gauge
|
||||||
|
}
|
||||||
|
|
||||||
|
func newMetrics() metrics {
|
||||||
|
configVersion := prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
|
Namespace: "supervisor",
|
||||||
|
Subsystem: "supervisor",
|
||||||
|
Name: "config_version",
|
||||||
|
Help: "Latest configuration version received from Cloudflare",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
prometheus.MustRegister(
|
||||||
|
configVersion,
|
||||||
|
)
|
||||||
|
return metrics{
|
||||||
|
configVersion: configVersion,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSupervisor(
|
func NewSupervisor(
|
||||||
|
@ -70,6 +92,7 @@ func NewSupervisor(
|
||||||
useConfigResultChan: useConfigResultChan,
|
useConfigResultChan: useConfigResultChan,
|
||||||
state: newState(defaultClientConfig),
|
state: newState(defaultClientConfig),
|
||||||
logger: logger.WithField("subsystem", "supervisor"),
|
logger: logger.WithField("subsystem", "supervisor"),
|
||||||
|
metrics: newMetrics(),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,6 +154,7 @@ func (s *Supervisor) notifySubsystemsNewConfig(newConfig *pogs.ClientConfig) *po
|
||||||
Success: true,
|
Success: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
s.metrics.configVersion.Set(float64(newConfig.Version))
|
||||||
|
|
||||||
s.state.updateConfig(newConfig)
|
s.state.updateConfig(newConfig)
|
||||||
var tunnelHostnames []h2mux.TunnelHostname
|
var tunnelHostnames []h2mux.TunnelHostname
|
||||||
|
|
Loading…
Reference in New Issue