Skip to content

Commit

Permalink
cmd: beacon alarm tool to monitor boot nodes agreeing on beacon values (
Browse files Browse the repository at this point in the history
#4704)

## Motivation

This tool is intended to be used to monitor if the bootnodes agree on the beacon value for the next epoch. It queries the central Mimir server for the metrics of all nodes of a given namespace and pushes its own metric to indicate if the bootnodes agree or not.

**NOTE:** The tool itself has been added to the internal tools repository. This PR now only includes some minor code changes (mostly exporting non-exported functions) that are needed for the tool to work properly.
  • Loading branch information
fasmat committed Apr 16, 2024
1 parent 0193a7f commit 9134829
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
8 changes: 7 additions & 1 deletion beacon/metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ type BeaconMetricsCollector struct {
calculatedBeaconWeight *prometheus.Desc
}

var nameCalculatedWeight = prometheus.BuildFQName(metrics.Namespace, subsystem, "beacon_calculated_weight")

func MetricNameCalculatedWeight() string {
return nameCalculatedWeight
}

// NewBeaconMetricsCollector creates a prometheus Collector for beacons.
func NewBeaconMetricsCollector(cb GatherCB, logger log.Logger) *BeaconMetricsCollector {
bmc := &BeaconMetricsCollector{
Expand All @@ -51,7 +57,7 @@ func NewBeaconMetricsCollector(cb GatherCB, logger log.Logger) *BeaconMetricsCol
"Weight of beacons collected from blocks for each epoch and value",
[]string{labelEpoch, labelBeacon}, nil),
calculatedBeaconWeight: prometheus.NewDesc(
prometheus.BuildFQName(metrics.Namespace, subsystem, "beacon_calculated_weight"),
nameCalculatedWeight,
"Weight of the beacon calculated by the node for each epoch",
[]string{labelEpoch, labelBeacon}, nil),
}
Expand Down
2 changes: 1 addition & 1 deletion log/logtest/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func New(tb testing.TB, override ...zapcore.Level) log.Log {
panic(err)
}
}
return log.NewFromLog(zaptest.NewLogger(tb, zaptest.Level(level)))
return log.NewFromLog(zaptest.NewLogger(tb, zaptest.Level(level))).Named(tb.Name())
}

// SetupGlobal updates AppLog to the instance of test-specific logger.
Expand Down
5 changes: 5 additions & 0 deletions log/zap.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ func String(name, val string) Field {
return Field(zap.String(name, val))
}

// Strings returns a strings Field.
func Strings(name string, val []string) Field {
return Field(zap.Strings(name, val))
}

// Stringer returns an fmt.Sringer Field.
func Stringer(name string, val fmt.Stringer) Field {
return Field(zap.Stringer(name, val))
Expand Down
4 changes: 2 additions & 2 deletions node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func loadConfig(cfg *config.Config, preset, path string) error {
viper.DecodeHook(hook),
WithZeroFields(),
WithIgnoreUntagged(),
withErrorUnused(),
WithErrorUnused(),
}

// load config if it was loaded to the viper
Expand All @@ -345,7 +345,7 @@ func WithIgnoreUntagged() viper.DecoderConfigOption {
}
}

func withErrorUnused() viper.DecoderConfigOption {
func WithErrorUnused() viper.DecoderConfigOption {
return func(cfg *mapstructure.DecoderConfig) {
cfg.ErrorUnused = true
}
Expand Down

0 comments on commit 9134829

Please sign in to comment.