metrics: enable during import (#2401)
This allows monitoring the import process using prometheus/grafana/etc
This commit is contained in:
parent
09946c9958
commit
83b3eeeb18
|
@ -258,6 +258,23 @@ type
|
||||||
defaultValue: 10
|
defaultValue: 10
|
||||||
name: "log-metrics-interval" .}: int
|
name: "log-metrics-interval" .}: int
|
||||||
|
|
||||||
|
metricsEnabled* {.
|
||||||
|
desc: "Enable the built-in metrics HTTP server"
|
||||||
|
defaultValue: false
|
||||||
|
name: "metrics" }: bool
|
||||||
|
|
||||||
|
metricsPort* {.
|
||||||
|
desc: "Listening port of the built-in metrics HTTP server"
|
||||||
|
defaultValue: defaultMetricsServerPort
|
||||||
|
defaultValueDesc: $defaultMetricsServerPort
|
||||||
|
name: "metrics-port" }: Port
|
||||||
|
|
||||||
|
metricsAddress* {.
|
||||||
|
desc: "Listening IP address of the built-in metrics HTTP server"
|
||||||
|
defaultValue: defaultAdminListenAddress
|
||||||
|
defaultValueDesc: $defaultAdminListenAddressDesc
|
||||||
|
name: "metrics-address" }: IpAddress
|
||||||
|
|
||||||
bootstrapNodes {.
|
bootstrapNodes {.
|
||||||
separator: "\pNETWORKING OPTIONS:"
|
separator: "\pNETWORKING OPTIONS:"
|
||||||
desc: "Specifies one or more bootstrap nodes(as enode URL) to use when connecting to the network"
|
desc: "Specifies one or more bootstrap nodes(as enode URL) to use when connecting to the network"
|
||||||
|
@ -478,23 +495,6 @@ type
|
||||||
defaultValueDesc: "\"jwt.hex\" in the data directory (see --data-dir)"
|
defaultValueDesc: "\"jwt.hex\" in the data directory (see --data-dir)"
|
||||||
name: "jwt-secret" .}: Option[InputFile]
|
name: "jwt-secret" .}: Option[InputFile]
|
||||||
|
|
||||||
metricsEnabled* {.
|
|
||||||
desc: "Enable the built-in metrics HTTP server"
|
|
||||||
defaultValue: false
|
|
||||||
name: "metrics" }: bool
|
|
||||||
|
|
||||||
metricsPort* {.
|
|
||||||
desc: "Listening port of the built-in metrics HTTP server"
|
|
||||||
defaultValue: defaultMetricsServerPort
|
|
||||||
defaultValueDesc: $defaultMetricsServerPort
|
|
||||||
name: "metrics-port" }: Port
|
|
||||||
|
|
||||||
metricsAddress* {.
|
|
||||||
desc: "Listening IP address of the built-in metrics HTTP server"
|
|
||||||
defaultValue: defaultAdminListenAddress
|
|
||||||
defaultValueDesc: $defaultAdminListenAddressDesc
|
|
||||||
name: "metrics-address" }: IpAddress
|
|
||||||
|
|
||||||
of `import`:
|
of `import`:
|
||||||
blocksFile* {.
|
blocksFile* {.
|
||||||
argument
|
argument
|
||||||
|
|
|
@ -174,8 +174,7 @@ proc setupP2P(nimbus: NimbusNode, conf: NimbusConf,
|
||||||
waitForPeers = waitForPeers)
|
waitForPeers = waitForPeers)
|
||||||
|
|
||||||
|
|
||||||
proc localServices(nimbus: NimbusNode, conf: NimbusConf,
|
proc setupMetrics(nimbus: NimbusNode, conf: NimbusConf) =
|
||||||
com: CommonRef, protocols: set[ProtocolFlag]) =
|
|
||||||
# metrics logging
|
# metrics logging
|
||||||
if conf.logMetricsEnabled:
|
if conf.logMetricsEnabled:
|
||||||
# https://github.com/nim-lang/Nim/issues/17369
|
# https://github.com/nim-lang/Nim/issues/17369
|
||||||
|
@ -187,8 +186,6 @@ proc localServices(nimbus: NimbusNode, conf: NimbusConf,
|
||||||
discard setTimer(Moment.fromNow(conf.logMetricsInterval.seconds), logMetrics)
|
discard setTimer(Moment.fromNow(conf.logMetricsInterval.seconds), logMetrics)
|
||||||
discard setTimer(Moment.fromNow(conf.logMetricsInterval.seconds), logMetrics)
|
discard setTimer(Moment.fromNow(conf.logMetricsInterval.seconds), logMetrics)
|
||||||
|
|
||||||
nimbus.setupRpc(conf, com, protocols)
|
|
||||||
|
|
||||||
# metrics server
|
# metrics server
|
||||||
if conf.metricsEnabled:
|
if conf.metricsEnabled:
|
||||||
info "Starting metrics HTTP server", address = conf.metricsAddress, port = conf.metricsPort
|
info "Starting metrics HTTP server", address = conf.metricsAddress, port = conf.metricsPort
|
||||||
|
@ -235,6 +232,8 @@ proc run(nimbus: NimbusNode, conf: NimbusConf) =
|
||||||
of Aristo,AriPrune:
|
of Aristo,AriPrune:
|
||||||
AristoDbRocks.newCoreDbRef(string conf.dataDir, conf.dbOptions())
|
AristoDbRocks.newCoreDbRef(string conf.dataDir, conf.dbOptions())
|
||||||
|
|
||||||
|
setupMetrics(nimbus, conf)
|
||||||
|
|
||||||
let com = CommonRef.new(
|
let com = CommonRef.new(
|
||||||
db = coreDB,
|
db = coreDB,
|
||||||
pruneHistory = (conf.chainDbMode == AriPrune),
|
pruneHistory = (conf.chainDbMode == AriPrune),
|
||||||
|
@ -255,7 +254,7 @@ proc run(nimbus: NimbusNode, conf: NimbusConf) =
|
||||||
basicServices(nimbus, conf, com)
|
basicServices(nimbus, conf, com)
|
||||||
manageAccounts(nimbus, conf)
|
manageAccounts(nimbus, conf)
|
||||||
setupP2P(nimbus, conf, com, protocols)
|
setupP2P(nimbus, conf, com, protocols)
|
||||||
localServices(nimbus, conf, com, protocols)
|
setupRpc(nimbus, conf, com, protocols)
|
||||||
|
|
||||||
if conf.maxPeers > 0:
|
if conf.maxPeers > 0:
|
||||||
case conf.syncMode:
|
case conf.syncMode:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
import
|
import
|
||||||
chronicles,
|
chronicles,
|
||||||
|
metrics,
|
||||||
chronos/timer,
|
chronos/timer,
|
||||||
std/[strformat, strutils],
|
std/[strformat, strutils],
|
||||||
stew/io2,
|
stew/io2,
|
||||||
|
@ -20,6 +21,15 @@ import
|
||||||
./db/era1_db,
|
./db/era1_db,
|
||||||
beacon_chain/era_db
|
beacon_chain/era_db
|
||||||
|
|
||||||
|
declareCounter nec_imported_blocks,
|
||||||
|
"Blocks processed during import"
|
||||||
|
|
||||||
|
declareCounter nec_imported_transactions,
|
||||||
|
"Transactions processed during import"
|
||||||
|
|
||||||
|
declareCounter nec_imported_gas,
|
||||||
|
"Gas processed during import"
|
||||||
|
|
||||||
var running {.volatile.} = true
|
var running {.volatile.} = true
|
||||||
|
|
||||||
func shortLog(a: timer.Duration, parts = int.high): string {.inline.} =
|
func shortLog(a: timer.Duration, parts = int.high): string {.inline.} =
|
||||||
|
@ -145,6 +155,10 @@ proc importBlocks*(conf: NimbusConf, com: CommonRef) =
|
||||||
avgMGps = f(gas.float / 1000000 / diff0),
|
avgMGps = f(gas.float / 1000000 / diff0),
|
||||||
elapsed = shortLog(time2 - time0, 3)
|
elapsed = shortLog(time2 - time0, 3)
|
||||||
|
|
||||||
|
nec_imported_blocks.inc(blocks.len)
|
||||||
|
nec_imported_transactions.inc(statsRes[].txs)
|
||||||
|
nec_imported_gas.inc(statsRes[].gas)
|
||||||
|
|
||||||
if csv != nil:
|
if csv != nil:
|
||||||
# In the CSV, we store a line for every chunk of blocks processed so
|
# In the CSV, we store a line for every chunk of blocks processed so
|
||||||
# that the file can meaningfully be appended to when restarting the
|
# that the file can meaningfully be appended to when restarting the
|
||||||
|
|
Loading…
Reference in New Issue