TUN-5703: Add prometheus metric for current configuration version

This commit is contained in:
Devin Carr 2022-03-09 15:16:54 -08:00
parent a50c0ca9ad
commit 8cbd222e10
2 changed files with 26 additions and 0 deletions

25
orchestration/metrics.go Normal file
View File

@ -0,0 +1,25 @@
package orchestration
import (
"github.com/prometheus/client_golang/prometheus"
)
const (
MetricsNamespace = "cloudflared"
MetricsSubsystem = "orchestration"
)
var (
configVersion = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: MetricsNamespace,
Subsystem: MetricsSubsystem,
Name: "config_version",
Help: "Configuration Version",
},
)
)
func init() {
prometheus.MustRegister(configVersion)
}

View File

@ -95,6 +95,7 @@ func (o *Orchestrator) UpdateConfig(version int32, config []byte) *tunnelpogs.Up
Int32("version", version).
Str("config", string(config)).
Msg("Updated to new configuration")
configVersion.Set(float64(version))
return &tunnelpogs.UpdateConfigurationResponse{
LastAppliedVersion: o.currentVersion,
}