Skip to content

Commit

Permalink
feat: add moniker and tendermint version (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno authored Mar 24, 2024
1 parent a12c173 commit 037a9fa
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/clients/tendermint/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type StatusResult struct {

type NodeInfo struct {
Moniker string `json:"moniker"`
Version string `json:"version"`
}

type SyncInfo struct {
Expand Down
16 changes: 16 additions & 0 deletions pkg/metrics/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,22 @@ func NewManager(config *configPkg.Config) *Manager {
[]string{"node"},
),

MetricNameMoniker: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: constants.MetricsPrefix + "moniker",
Help: "Node moniker, always 1",
},
[]string{"node", "moniker"},
),

MetricNameTendermintVersion: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: constants.MetricsPrefix + "tendermint_version",
Help: "Tendermint/CometBFT version, always 1",
},
[]string{"node", "version"},
),

MetricNameRemoteVersion: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: constants.MetricsPrefix + "remote_version",
Expand Down
2 changes: 2 additions & 0 deletions pkg/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const (
MetricNameCosmovisorVersion = "cosmovisor_version"
MetricNameCatchingUp = "catching_up"
MetricNameTimeSinceLatestBlock = "time_since_latest_block"
MetricNameMoniker = "Moniker"
MetricNameTendermintVersion = "tendermint_version"
MetricNameVotingPower = "voting_power"
MetricNameRemoteVersion = "remote_version"
MetricNameLocalVersion = "local_version"
Expand Down
10 changes: 10 additions & 0 deletions pkg/queriers/node_stats/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ func (n *Querier) Get() ([]metrics.MetricInfo, []query_info.QueryInfo) {
Labels: map[string]string{},
Value: time.Since(status.Result.SyncInfo.LatestBlockTime).Seconds(),
},
{
MetricName: metrics.MetricNameMoniker,
Labels: map[string]string{"moniker": status.Result.NodeInfo.Moniker},
Value: 1,
},
{
MetricName: metrics.MetricNameTendermintVersion,
Labels: map[string]string{"version": status.Result.NodeInfo.Version},
Value: 1,
},
}

if value, err := utils.StringToFloat64(status.Result.ValidatorInfo.VotingPower); err != nil {
Expand Down

0 comments on commit 037a9fa

Please sign in to comment.