Jakub Sokołowski
714eb416d2
Because `p2p.Server.Name()` function started returning an abbreviated name of the node this broke the parsing of the name in order to fill in the labels for `p2p_peers_count` metric, resulting in metrics like this: ```sh > curl -sS localhost:9090/metrics | grep '^p2p_peers_count' p2p_peers_count{platform="v0.79.0",type="Statusd",version="unknown"} 3 ``` Caused by value returned from `Name()` to look like this: ``` Statusd/v0.79.0/linu... ``` By using `Fullname()` we are sure we are pasing all the segments. Signed-off-by: Jakub Sokołowski <jakub@status.im> |
||
---|---|---|
.. | ||
node | ||
README.md | ||
metrics.go |
README.md
Description
This package configures Prometheus metrics for the node.
Technical Details
We use a trick to combine our metrics with Geth ones.
The NewMetricsServer()
function in metrics.go
calls our own Handler()
function which in turn calls two handlers:
promhttp.HandlerFor()
- Our own custom metrics from this package.gethprom.Handler(reg)
- Geth metrics defined inmetrics
By calling both we can extend existing metrics.
Metrics
We add a few extra metrics on top of the normal Geth ones in node/metrics.go
:
p2p_peers_count
- Current numbers of peers split by name.p2p_peers_absolute
- Absolute number of connected peers.p2p_peers_max
- Maximum number of peers that can connect.
The p2p_peers_count
metrics includes 3 labels:
type
- Set toStatusIM
for mobile andStatusd
for daemon.version
- Version ofstatus-go
, always with thev
prefix.platform
- Host platform, likeandroid-arm64
ordarwin-arm64
The way this data is acquired is using node names, which look like this:
StatusIM/vrelease-0.30.1-beta.2/android-arm/go1.11.5
Statusd/v0.34.0-beta.3/linux-amd64/go1.13.1
Geth/v1.9.9-stable-5aa131ca/linux-amd64/go1.13.3
This 4 segment format is standard for Ethereum as you can see on https://ethstats.net/.
We parse the names using labelsFromNodeName()
from node/metrics.go
.