|
|
@ -8,6 +8,8 @@ import ( |
|
|
|
stdprometheus "github.com/prometheus/client_golang/prometheus" |
|
|
|
) |
|
|
|
|
|
|
|
const MetricsSubsystem = "consensus" |
|
|
|
|
|
|
|
// Metrics contains metrics exposed by this package.
|
|
|
|
type Metrics struct { |
|
|
|
// Height of the chain.
|
|
|
@ -38,74 +40,102 @@ type Metrics struct { |
|
|
|
BlockSizeBytes metrics.Gauge |
|
|
|
// Total number of transactions.
|
|
|
|
TotalTxs metrics.Gauge |
|
|
|
// The latest block height.
|
|
|
|
CommittedHeight metrics.Gauge |
|
|
|
// Whether or not a node is fast syncing. 1 if yes, 0 if no.
|
|
|
|
FastSyncing metrics.Gauge |
|
|
|
} |
|
|
|
|
|
|
|
// PrometheusMetrics returns Metrics build using Prometheus client library.
|
|
|
|
func PrometheusMetrics() *Metrics { |
|
|
|
func PrometheusMetrics(namespace string) *Metrics { |
|
|
|
return &Metrics{ |
|
|
|
Height: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "height", |
|
|
|
Help: "Height of the chain.", |
|
|
|
}, []string{}), |
|
|
|
Rounds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "rounds", |
|
|
|
Help: "Number of rounds.", |
|
|
|
}, []string{}), |
|
|
|
|
|
|
|
Validators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "validators", |
|
|
|
Help: "Number of validators.", |
|
|
|
}, []string{}), |
|
|
|
ValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "validators_power", |
|
|
|
Help: "Total power of all validators.", |
|
|
|
}, []string{}), |
|
|
|
MissingValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "missing_validators", |
|
|
|
Help: "Number of validators who did not sign.", |
|
|
|
}, []string{}), |
|
|
|
MissingValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "missing_validators_power", |
|
|
|
Help: "Total power of the missing validators.", |
|
|
|
}, []string{}), |
|
|
|
ByzantineValidators: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "byzantine_validators", |
|
|
|
Help: "Number of validators who tried to double sign.", |
|
|
|
}, []string{}), |
|
|
|
ByzantineValidatorsPower: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "byzantine_validators_power", |
|
|
|
Help: "Total power of the byzantine validators.", |
|
|
|
}, []string{}), |
|
|
|
|
|
|
|
BlockIntervalSeconds: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "block_interval_seconds", |
|
|
|
Help: "Time between this and the last block.", |
|
|
|
}, []string{}), |
|
|
|
|
|
|
|
NumTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "num_txs", |
|
|
|
Help: "Number of transactions.", |
|
|
|
}, []string{}), |
|
|
|
BlockSizeBytes: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "block_size_bytes", |
|
|
|
Help: "Size of the block.", |
|
|
|
}, []string{}), |
|
|
|
TotalTxs: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Subsystem: "consensus", |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "total_txs", |
|
|
|
Help: "Total number of transactions.", |
|
|
|
}, []string{}), |
|
|
|
CommittedHeight: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "latest_block_height", |
|
|
|
Help: "The latest block height.", |
|
|
|
}, []string{}), |
|
|
|
FastSyncing: prometheus.NewGaugeFrom(stdprometheus.GaugeOpts{ |
|
|
|
Namespace: namespace, |
|
|
|
Subsystem: MetricsSubsystem, |
|
|
|
Name: "fast_syncing", |
|
|
|
Help: "Whether or not a node is fast syncing. 1 if yes, 0 if no.", |
|
|
|
}, []string{}), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -125,8 +155,10 @@ func NopMetrics() *Metrics { |
|
|
|
|
|
|
|
BlockIntervalSeconds: discard.NewGauge(), |
|
|
|
|
|
|
|
NumTxs: discard.NewGauge(), |
|
|
|
BlockSizeBytes: discard.NewGauge(), |
|
|
|
TotalTxs: discard.NewGauge(), |
|
|
|
NumTxs: discard.NewGauge(), |
|
|
|
BlockSizeBytes: discard.NewGauge(), |
|
|
|
TotalTxs: discard.NewGauge(), |
|
|
|
CommittedHeight: discard.NewGauge(), |
|
|
|
FastSyncing: discard.NewGauge(), |
|
|
|
} |
|
|
|
} |