From 8cbd222e1097a5c07d7060f6831d6af820e354e5 Mon Sep 17 00:00:00 2001 From: Devin Carr Date: Wed, 9 Mar 2022 15:16:54 -0800 Subject: [PATCH] TUN-5703: Add prometheus metric for current configuration version --- orchestration/metrics.go | 25 +++++++++++++++++++++++++ orchestration/orchestrator.go | 1 + 2 files changed, 26 insertions(+) create mode 100644 orchestration/metrics.go diff --git a/orchestration/metrics.go b/orchestration/metrics.go new file mode 100644 index 00000000..1fa5e8a5 --- /dev/null +++ b/orchestration/metrics.go @@ -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) +} diff --git a/orchestration/orchestrator.go b/orchestration/orchestrator.go index d072e966..59d8db57 100644 --- a/orchestration/orchestrator.go +++ b/orchestration/orchestrator.go @@ -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, }