Merge pull request #612 from owncloud/glauth-metrics-buildinfo

add build information to metrics
This commit is contained in:
David Christofas
2020-09-28 17:20:43 +02:00
committed by GitHub
6 changed files with 22 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
Enhancement: add build information to the metrics
Added a new field to the metrics to show build information like the version.
https://github.com/owncloud/product/issues/226

View File

@@ -32,6 +32,7 @@ func Execute() error {
Flags: flagset.RootWithConfig(cfg),
Before: func(c *cli.Context) error {
cfg.Version = version.String
return ParseConfig(c, cfg)
},

View File

@@ -2,6 +2,7 @@ package command
import (
"context"
"github.com/owncloud/ocis/glauth/pkg/metrics"
"os"
"os/signal"
"strings"
@@ -134,11 +135,13 @@ func Server(cfg *config.Config) *cli.Command {
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
//metrics = metrics.New()
metrics = metrics.New()
)
defer cancel()
metrics.BuildInfo.WithLabelValues(cfg.Version).Set(1)
{
cfg := glauthcfg.Config{
LDAP: glauthcfg.LDAP{

View File

@@ -66,6 +66,7 @@ type Config struct {
Ldap Ldap
Ldaps Ldaps
Backend Backend
Version string
}
// New initializes a new configuration with or without defaults.

View File

@@ -1,5 +1,7 @@
package metrics
import "github.com/prometheus/client_golang/prometheus"
var (
// Namespace defines the namespace for the defines metrics.
Namespace = "ocis"
@@ -11,6 +13,7 @@ var (
// Metrics defines the available metrics of this service.
type Metrics struct {
// Counter *prometheus.CounterVec
BuildInfo *prometheus.GaugeVec
}
// New initializes the available metrics.
@@ -22,6 +25,12 @@ func New() *Metrics {
// Name: "greet_total",
// Help: "How many greeting requests processed",
// }, []string{}),
BuildInfo: prometheus.NewGaugeVec(prometheus.GaugeOpts{
Namespace: Namespace,
Subsystem: Subsystem,
Name: "build_info",
Help: "Build Information",
}, []string{"version"}),
}
// prometheus.Register(

View File

@@ -7,6 +7,7 @@ import (
"github.com/owncloud/ocis/glauth/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/ocis/pkg/version"
)
// GLAuthCommand is the entrypoint for the glauth command.
@@ -31,6 +32,7 @@ func configureGLAuth(cfg *config.Config) *svcconfig.Config {
cfg.GLAuth.Log.Level = cfg.Log.Level
cfg.GLAuth.Log.Pretty = cfg.Log.Pretty
cfg.GLAuth.Log.Color = cfg.Log.Color
cfg.GLAuth.Version = version.String
if cfg.Tracing.Enabled {
cfg.GLAuth.Tracing.Enabled = cfg.Tracing.Enabled