diff --git a/cmd/neofs-net-monitor/main.go b/cmd/neofs-net-monitor/main.go index 7295969..fcf3996 100644 --- a/cmd/neofs-net-monitor/main.go +++ b/cmd/neofs-net-monitor/main.go @@ -10,7 +10,6 @@ import ( "strings" "syscall" - "github.com/nspcc-dev/neofs-net-monitor/pkg/monitor" "github.com/spf13/viper" "go.uber.org/zap" ) @@ -45,8 +44,6 @@ func main() { os.Exit(1) } - monitor.RegisterMetrics() - neofsMonitor.Start(ctx) neofsMonitor.Logger().Info("application started", zap.String("version", Version)) diff --git a/cmd/neofs-net-monitor/monitor.go b/cmd/neofs-net-monitor/monitor.go index 628ffee..07e7eb3 100644 --- a/cmd/neofs-net-monitor/monitor.go +++ b/cmd/neofs-net-monitor/monitor.go @@ -38,8 +38,10 @@ func New(ctx context.Context, cfg *viper.Viper) (*monitor.Monitor, error) { var job monitor.Job if cfg.GetBool(cfgChainFSChain) { + monitor.RegisterSideChainMetrics() job, err = sideChainJob(ctx, cfg, sideNeogoClient, logger, sideChainEndpoints) } else { + monitor.RegisterMainChainMetrics() job, err = mainChainJob(cfg, sideNeogoClient, logger) } diff --git a/pkg/monitor/metrics.go b/pkg/monitor/metrics.go index 5b0d8aa..4712046 100644 --- a/pkg/monitor/metrics.go +++ b/pkg/monitor/metrics.go @@ -169,8 +169,8 @@ var ( ) ) -// RegisterMetrics inits prometheus metrics. Panics if can't do it. -func RegisterMetrics() { +// RegisterSideChainMetrics inits prometheus metrics for side chain. Panics if can't do it. +func RegisterSideChainMetrics() { prometheus.MustRegister(locationPresent) prometheus.MustRegister(droppedNodesCount) prometheus.MustRegister(newNodesCount) @@ -178,13 +178,18 @@ func RegisterMetrics() { prometheus.MustRegister(storageNodeGASBalances) prometheus.MustRegister(storageNodeNotaryBalances) prometheus.MustRegister(innerRingBalances) - prometheus.MustRegister(alphabetGASBalances) prometheus.MustRegister(alphabetNotaryBalances) prometheus.MustRegister(proxyBalance) - prometheus.MustRegister(mainChainSupply) prometheus.MustRegister(sideChainSupply) - prometheus.MustRegister(alphabetPubKeys) + prometheus.MustRegister(alphabetPubKeys) // used for both monitors prometheus.MustRegister(containersNumber) prometheus.MustRegister(chainHeight) prometheus.MustRegister(chainState) } + +// RegisterMainChainMetrics inits prometheus metrics for main chain. Panics if can't do it. +func RegisterMainChainMetrics() { + prometheus.MustRegister(alphabetGASBalances) + prometheus.MustRegister(mainChainSupply) + prometheus.MustRegister(alphabetPubKeys) // used for both monitors +}