Skip to content

Commit

Permalink
Fix prometheus metrics [#3463]
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Oct 30, 2023
1 parent 38ee339 commit 012430b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/accumulated/cmd_init_dual_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ func finalizeDnn(bvnId string) (*cfg.Config, error) {
c.Consensus.CreateEmptyBlocks = false
}

c.Instrumentation.Namespace += "_" + strings.ToLower(c.Accumulate.PartitionId)

// if len(c.P2P.PersistentPeers) > 0 {
// c.P2P.BootstrapPeers = c.P2P.PersistentPeers
// c.P2P.PersistentPeers = ""
Expand Down Expand Up @@ -221,6 +223,8 @@ func finalizeBvnn() (*cfg.Config, error) {
c.Consensus.CreateEmptyBlocks = false
}

c.Instrumentation.Namespace += "_" + strings.ToLower(c.Accumulate.PartitionId)

//in dual mode, the key between bvn and dn is shared.
//This will be cleaned up when init system is overhauled with AC-1263
// if len(c.P2P.PersistentPeers) > 0 {
Expand Down
20 changes: 18 additions & 2 deletions cmd/accumulated/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -105,8 +106,23 @@ func (p *Program) Start() (err error) {
return err
}

// Only one node can run Prometheus
p.secondary.Config.Instrumentation.Prometheus = false
{
a := p.primary.Config.Instrumentation
b := p.secondary.Config.Instrumentation

// If both sub-nodes have the default instrumentation namespace,
// dynamically append the partition ID to it
if (a.Namespace == "tendermint" || a.Namespace == "cometbft") && (b.Namespace == "tendermint" || b.Namespace == "cometbft") {
a.Namespace += "_" + strings.ToLower(p.primary.Config.Accumulate.PartitionId)
b.Namespace += "_" + strings.ToLower(p.secondary.Config.Accumulate.PartitionId)
}

// If both sub-nodes still have the same instrumentation namespace,
// disable the second one to prevent conflicts
if a.Namespace == b.Namespace {
b.Prometheus = false
}
}

if flagRun.EnableTimingLogs {
p.secondary.Config.Accumulate.AnalysisLog.Enabled = true
Expand Down
3 changes: 3 additions & 0 deletions internal/node/daemon/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func BuildNodesConfig(network *NetworkInit, mkcfg MakeConfigFunc) [][][]*config.
Type: node.BvnnType,
})

dnn.Instrumentation.Namespace += fmt.Sprintf("_directory_%d", i)
bvnn.Instrumentation.Namespace += fmt.Sprintf("_%s_%d", strings.ToLower(bvn.Id), i)

if dnn.P2P.ExternalAddress == "" {
dnn.P2P.ExternalAddress = node.Peer().TendermintP2P().Directory().String()
}
Expand Down

0 comments on commit 012430b

Please sign in to comment.