mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-11 21:04:11 +00:00
metrics HTTP server replacing the periodic "stats" logging
and example prometheus.yml file to use it as a scraping target
This commit is contained in:
parent
003b2c3136
commit
2d9f62530b
8
examples/prometheus.yml
Normal file
8
examples/prometheus.yml
Normal file
@ -0,0 +1,8 @@
|
||||
global:
|
||||
scrape_interval: 1s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: "nimbus"
|
||||
static_configs:
|
||||
- targets: ['localhost:9093']
|
||||
|
@ -135,6 +135,7 @@ type
|
||||
staticNodes*: seq[ENode] ## List of static nodes to connect to
|
||||
bindPort*: uint16 ## Main TCP bind port
|
||||
discPort*: uint16 ## Discovery UDP bind port
|
||||
metricsPort*: uint16 ## metrics HTTP server port
|
||||
maxPeers*: int ## Maximum allowed number of peers
|
||||
maxPendingPeers*: int ## Maximum allowed pending peers
|
||||
networkId*: uint ## Network ID as integer
|
||||
@ -493,6 +494,11 @@ proc processNetArguments(key, value: string): ConfigStatus =
|
||||
result = processInteger(value, res)
|
||||
if result == Success:
|
||||
config.net.discPort = uint16(res and 0xFFFF)
|
||||
elif skey == "metricsport":
|
||||
var res = 0
|
||||
result = processInteger(value, res)
|
||||
if result == Success:
|
||||
config.net.metricsPort = uint16(res and 0xFFFF)
|
||||
elif skey == "maxpeers":
|
||||
var res = 0
|
||||
result = processInteger(value, res)
|
||||
@ -626,6 +632,7 @@ proc initConfiguration(): NimbusConfiguration =
|
||||
result.net.maxPendingPeers = 0
|
||||
result.net.bindPort = 30303'u16
|
||||
result.net.discPort = 30303'u16
|
||||
result.net.metricsPort = 9093'u16
|
||||
result.net.ident = NimbusIdent
|
||||
result.net.nat = NatAny
|
||||
result.net.protocols = defaultProtocols
|
||||
@ -675,6 +682,7 @@ NETWORKING OPTIONS:
|
||||
--staticnodes:<value> Comma separated enode URLs to connect with
|
||||
--port:<value> Network listening TCP port (default: 30303)
|
||||
--discport:<value> Network listening UDP port (defaults to --port argument)
|
||||
--metricsport:<value> Metrics HTTP server port on localhost (defaults to 9093, set to 0 to disable)
|
||||
--maxpeers:<value> Maximum number of network peers (default: 25)
|
||||
--maxpendpeers:<value> Maximum number of pending connection attempts (default: 0)
|
||||
--nat:<value> NAT port mapping mechanism (any|none|upnp|pmp|<external IP>) (default: "any")
|
||||
|
@ -15,7 +15,7 @@ import
|
||||
eth/p2p/rlpx_protocols/[eth_protocol, les_protocol, whisper_protocol],
|
||||
eth/p2p/blockchain_sync, eth/net/nat, eth/p2p/peer_pool,
|
||||
config, genesis, rpc/[common, p2p, debug, whisper], p2p/chain,
|
||||
eth/trie/db
|
||||
eth/trie/db, metrics
|
||||
|
||||
## TODO:
|
||||
## * No IPv6 support
|
||||
@ -136,14 +136,11 @@ proc start() =
|
||||
result = "EXITING"
|
||||
nimbus.rpcServer.start()
|
||||
|
||||
# periodically log internal statistics
|
||||
let statsInterval = 10.seconds
|
||||
proc printStats(udata: pointer) {.closure, gcsafe.} =
|
||||
{.gcsafe.}:
|
||||
let peers = peerGauge.value.int64
|
||||
info "stats", peers
|
||||
addTimer(Moment.fromNow(statsInterval), printStats)
|
||||
addTimer(Moment.fromNow(statsInterval), printStats)
|
||||
# metrics
|
||||
if conf.net.metricsPort > 0.uint16:
|
||||
let metricsAddress = "127.0.0.1"
|
||||
info "Starting metrics HTTP server", address = metricsAddress, port = conf.net.metricsPort
|
||||
metrics.startHttpServer(metricsAddress, Port(conf.net.metricsPort))
|
||||
|
||||
# Connect directly to the static nodes
|
||||
for enode in conf.net.staticNodes:
|
||||
|
Loading…
x
Reference in New Issue
Block a user