diff --git a/main.go b/main.go index 5396a39..35dda76 100644 --- a/main.go +++ b/main.go @@ -396,7 +396,7 @@ func Main(config *Config, configTest bool, buildVersion string, logger *logrus.L go lightHouse.LhUpdateWorker(ifce) } - err = startStats(l, config, configTest) + err = startStats(l, config, buildVersion, configTest) if err != nil { return nil, NewContextualError("Failed to start stats emitter", nil, err) } diff --git a/stats.go b/stats.go index e09966e..76be8ce 100644 --- a/stats.go +++ b/stats.go @@ -6,6 +6,7 @@ import ( "log" "net" "net/http" + "runtime" "time" graphite "github.com/cyberdelia/go-metrics-graphite" @@ -16,7 +17,7 @@ import ( "github.com/sirupsen/logrus" ) -func startStats(l *logrus.Logger, c *Config, configTest bool) error { +func startStats(l *logrus.Logger, c *Config, buildVersion string, configTest bool) error { mType := c.GetString("stats.type", "") if mType == "" || mType == "none" { return nil @@ -31,7 +32,7 @@ func startStats(l *logrus.Logger, c *Config, configTest bool) error { case "graphite": startGraphiteStats(l, interval, c, configTest) case "prometheus": - startPrometheusStats(l, interval, c, configTest) + startPrometheusStats(l, interval, c, buildVersion, configTest) default: return fmt.Errorf("stats.type was not understood: %s", mType) } @@ -65,7 +66,7 @@ func startGraphiteStats(l *logrus.Logger, i time.Duration, c *Config, configTest return nil } -func startPrometheusStats(l *logrus.Logger, i time.Duration, c *Config, configTest bool) error { +func startPrometheusStats(l *logrus.Logger, i time.Duration, c *Config, buildVersion string, configTest bool) error { namespace := c.GetString("stats.namespace", "") subsystem := c.GetString("stats.subsystem", "") @@ -83,6 +84,20 @@ func startPrometheusStats(l *logrus.Logger, i time.Duration, c *Config, configTe pClient := mp.NewPrometheusProvider(metrics.DefaultRegistry, namespace, subsystem, pr, i) go pClient.UpdatePrometheusMetrics() + // Export our version information as labels on a static gauge + g := prometheus.NewGauge(prometheus.GaugeOpts{ + Namespace: namespace, + Subsystem: subsystem, + Name: "info", + Help: "Version information for the Nebula binary", + ConstLabels: prometheus.Labels{ + "version": buildVersion, + "goversion": runtime.Version(), + }, + }) + pr.MustRegister(g) + g.Set(1) + if !configTest { go func() { l.Infof("Prometheus stats listening on %s at %s", listen, path)