Skip to content

Commit

Permalink
Add central management telemetry (#8671)
Browse files Browse the repository at this point in the history
* Add central management telmetry

This will report central management enabled status
  • Loading branch information
exekias committed Oct 23, 2018
1 parent e6f3a6e commit 96e484c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libbeat/cmd/instance/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ func (b *Beat) createBeater(bt beat.Creator) (beat.Beater, error) {
return nil, err
}

// Report central management state
mgmt := monitoring.GetNamespace("state").GetRegistry().NewRegistry("management")
monitoring.NewBool(mgmt, "enabled").Set(b.ConfigManager.Enabled())

debugf("Initializing output plugins")
outputEnabled := b.Config.Output.IsSet() && b.Config.Output.Config().Enabled()
if !outputEnabled {
Expand Down
24 changes: 24 additions & 0 deletions libbeat/monitoring/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,30 @@ func (v *Float) Add(delta float64) {
}
}

// Bool is a Bool variable satisfying the Var interface.
type Bool struct{ f atomic.Bool }

// NewBool creates and registers a new bool variable.
//
// Note: If the registry is configured to publish variables to expvar, the
// variable will be available via expvars package as well, but can not be removed
// anymore.
func NewBool(r *Registry, name string, opts ...Option) *Bool {
if r == nil {
r = Default
}

v := &Bool{}
addVar(r, name, opts, v, makeExpvar(func() string {
return strconv.FormatBool(v.Get())
}))
return v
}

func (v *Bool) Get() bool { return v.f.Load() }
func (v *Bool) Set(value bool) { v.f.Store(value) }
func (v *Bool) Visit(_ Mode, vs Visitor) { vs.OnBool(v.Get()) }

// String is a string variable satisfying the Var interface.
type String struct {
mu sync.RWMutex
Expand Down

0 comments on commit 96e484c

Please sign in to comment.