Skip to content

Commit

Permalink
feat: add manager name to runtime info metric
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhop committed May 8, 2023
1 parent 0b54c07 commit bee4134
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions cmd/mango/mango.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
Name: "mango_runtime_info",
Help: "A metric with a constant '1' value with labels for information about the mango runtime, such as system hostname.",
},
[]string{"hostname", "enrolled"},
[]string{"hostname", "enrolled", "manager"},
)
)

Expand Down Expand Up @@ -99,18 +99,23 @@ func mango(inventoryPath, hostname string) {
// reload inventory
inv.Reload(ctx)
enrolled := inv.IsEnrolled()
metricMangoRuntimeInfo.With(prometheus.Labels{"hostname": hostname, "enrolled": strconv.FormatBool(enrolled)}).Set(1)
log.WithFields(log.Fields{
"hostname": hostname,
"enrolled": enrolled,
}).Info("Host enrollment check")

// start manager, reload it with data from inventory, and then start a run of everything for the system
log.WithFields(log.Fields{
"manager": hostname,
}).Info("Initializing mango manager")
mgr := manager.NewManager(hostname)
mgr.Reload(ctx, inv)
metricMangoRuntimeInfo.With(prometheus.Labels{
"hostname": hostname,
"enrolled": strconv.FormatBool(enrolled),
"manager": mgr.String(),
}).Set(1)
log.WithFields(log.Fields{
"hostname": hostname,
"enrolled": enrolled,
"manager": mgr.String(),
}).Info("Host enrollment check")

log.Info("Starting initial run of all modules")
mgr.RunAll(ctx)
Expand Down

0 comments on commit bee4134

Please sign in to comment.