collect height and target-height from info

this way we can figure out how far we are from the main chain's height
during sync

Signed-off-by: Ciro S. Costa <utxobr@protonmail.com>
This commit is contained in:
Ciro S. Costa 2021-08-03 17:05:09 -04:00
parent 2b828d59b3
commit 5febff4a8d
5 changed files with 38 additions and 6 deletions

View File

@ -3,7 +3,7 @@ kind: Config
minimumRequiredVersion: 0.30.0
overrides:
- image: monero-exporter
newImage: index.docker.io/utxobr/monero-exporter@sha256:da1a13e78a9aeacac10b576824d4195a14bc1e5ba9919770d2f81cb9d32c0d4d
newImage: index.docker.io/utxobr/monero-exporter@sha256:c5c019718c37c40cf4335405d47e7fe46b892e55ff74a712bd49e084c8bb02b1
preresolved: true
- image: monero-exporter-grafana
newImage: index.docker.io/utxobr/monero-exporter-grafana@sha256:f9c47963d3fb573166881baf1a9f2ad331500e34b4604d430f96957ab7bb1449

View File

@ -303,12 +303,14 @@ General information about this node.
| monero_info_alternative_blocks | number of blocks alternative to the longest |
| monero_info_block_size_limit | maximum hard limit of a block |
| monero_info_block_size_median | current median size for computing dynamic fees |
| monero_info_height | current height of the chain |
| monero_info_mainnet | whether the node is connected to mainnet |
| monero_info_offline | whether the node is offline |
| monero_info_synchronized | |
| monero_info_rpc_connections | number of rpc connections being served by the node |
| monero_info_synchronized | whether the node's chain is in sync with the network|
| monero_info_target_height | target height to achieve to be considered in sync |
| monero_info_uptime_seconds_total | for how long this node has been up |
## License
See [LICENSE](./LICENSE).

View File

@ -15,7 +15,7 @@ services:
command:
- --monero-addr=http://127.0.0.1:18081
container_name: monero-exporter
image: index.docker.io/utxobr/monero-exporter@sha256:da1a13e78a9aeacac10b576824d4195a14bc1e5ba9919770d2f81cb9d32c0d4d
image: index.docker.io/utxobr/monero-exporter@sha256:c5c019718c37c40cf4335405d47e7fe46b892e55ff74a712bd49e084c8bb02b1
network_mode: service:monerod
monerod:
command:

View File

@ -5,7 +5,7 @@
#
# [1] - https://help.github.com/articles/organizing-information-with-tables/
#
# Usage: `curl -s localhost:9100/metrics | grep container_ | ./gh-table-printer`
# Usage: `curl -s localhost:9000/metrics | grep monero_ | ./gh-table-printer`
BEGIN {
print "| name | description |"

View File

@ -122,12 +122,42 @@ func (c *OverallCollector) collect() {
c.metricsC <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
"monero_info_synchronized",
"",
"whether the node's chain is in sync with the network",
nil, nil,
),
prometheus.GaugeValue,
boolToFloat64(c.info.Synchronized),
)
c.metricsC <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
"monero_info_height",
"current height of the chain",
nil, nil,
),
prometheus.GaugeValue,
float64(c.info.Height),
)
c.metricsC <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
"monero_info_target_height",
"target height to achieve to be considered in sync",
nil, nil,
),
prometheus.GaugeValue,
float64(c.info.TargetHeight),
)
c.metricsC <- prometheus.MustNewConstMetric(
prometheus.NewDesc(
"monero_info_rpc_connections",
"number of rpc connections being served by the node",
nil, nil,
),
prometheus.GaugeValue,
float64(c.info.RPCConnectionsCount),
)
}
func boolToFloat64(b bool) float64 {