mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 11:41:19 +00:00
Fix metrics conflict with pporf (#1112)
This commit is contained in:
parent
065e658f42
commit
3a4eb3db3e
@ -1,8 +1,8 @@
|
||||
Build: `cd cmd/prometheus && docker-compose build --parallel`
|
||||
Build: `docker-compose build --parallel`
|
||||
|
||||
Run only Prometheus: `cd cmd/prometheus && docker-compose up prometheus grafana`
|
||||
Run only Prometheus: `docker-compose up prometheus grafana`
|
||||
|
||||
Run with TurboGeth, RestApi and DebugUI: `cd cmd/prometheus && TGETH_DATADIR=/path/to/geth/data/dir docker-compose up`
|
||||
Run with TurboGeth, RestApi and DebugUI: `XDG_DATA_HOME=/path/to/geth/data/dir docker-compose up`
|
||||
|
||||
Grafana: [localhost:3000](localhost:3000), admin/admin
|
||||
DebugUI: [localhost:3001](localhost:3001)
|
||||
|
@ -16,12 +16,12 @@ scrape_configs:
|
||||
scheme: http
|
||||
static_configs:
|
||||
- targets:
|
||||
- turbo-geth:6060
|
||||
- turbo-geth:6061
|
||||
- turbo-geth:6062
|
||||
- host.docker.internal:6060
|
||||
- host.docker.internal:6061
|
||||
- host.docker.internal:6062
|
||||
- turbo-geth:6060
|
||||
- turbo-geth:6061
|
||||
- turbo-geth:6062
|
||||
- host.docker.internal:6060 # this is how docker-for-mac allow to access host machine
|
||||
- host.docker.internal:6061
|
||||
- host.docker.internal:6062
|
||||
|
||||
- job_name: turbo-geth2
|
||||
metrics_path: /debug/metrics/prometheus2
|
||||
|
@ -5,14 +5,14 @@ services:
|
||||
turbo-geth:
|
||||
image: turbo-geth:latest
|
||||
build: .
|
||||
command: tg --metrics --pprof.addr="0.0.0.0" --pprof.port="6060" --private.api.addr="0.0.0.0:9090" --ipcdisable
|
||||
command: tg --metrics --metrics.addr="0.0.0.0" --metrics.port="6060" --private.api.addr="0.0.0.0:9090" --pprof --pprof.addr="0.0.0.0" --pprof.port="6061"
|
||||
volumes:
|
||||
- ${XDG_DATA_HOME:-~/.local/share}/turbogeth:/root/.local/share/turbogeth
|
||||
ports:
|
||||
- 30303:30303
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:v2.20.1
|
||||
image: prom/prometheus:v2.21.0
|
||||
command: --log.level=warn --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus --web.console.libraries=/usr/share/prometheus/console_libraries --web.console.templates=/usr/share/prometheus/consoles
|
||||
ports:
|
||||
- 9090:9090
|
||||
|
@ -92,16 +92,6 @@ var (
|
||||
Usage: "Write execution trace to the given file",
|
||||
}
|
||||
// (Deprecated April 2020)
|
||||
legacyPprofPortFlag = cli.IntFlag{
|
||||
Name: "pprofport",
|
||||
Usage: "pprof HTTP server listening port (deprecated, use --pprof.port)",
|
||||
Value: 6060,
|
||||
}
|
||||
legacyPprofAddrFlag = cli.StringFlag{
|
||||
Name: "pprofaddr",
|
||||
Usage: "pprof HTTP server listening interface (deprecated, use --pprof.addr)",
|
||||
Value: "127.0.0.1",
|
||||
}
|
||||
legacyMemprofilerateFlag = cli.IntFlag{
|
||||
Name: "memprofilerate",
|
||||
Usage: "Turn on memory profiling with the given rate (deprecated, use --pprof.memprofilerate)",
|
||||
@ -125,7 +115,7 @@ var Flags = []cli.Flag{
|
||||
}
|
||||
|
||||
var DeprecatedFlags = []cli.Flag{
|
||||
legacyPprofPortFlag, legacyPprofAddrFlag, legacyMemprofilerateFlag,
|
||||
legacyMemprofilerateFlag,
|
||||
legacyBlockprofilerateFlag, legacyCpuprofileFlag,
|
||||
}
|
||||
|
||||
@ -276,24 +266,31 @@ func Setup(ctx *cli.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Printf("ctx.GlobalBool(pprofFlag.Name): %v\n", ctx.GlobalBool(pprofFlag.Name))
|
||||
|
||||
if metrics.Enabled {
|
||||
go metrics.CollectProcessMetrics(3 * time.Second) // Start system runtime metrics collection
|
||||
}
|
||||
|
||||
pprofEnabled := ctx.GlobalBool(pprofFlag.Name)
|
||||
metricsAddr := ctx.GlobalString(metricsAddrFlag.Name)
|
||||
|
||||
if metrics.Enabled && (!pprofEnabled || metricsAddr != "") {
|
||||
metricsPort := ctx.GlobalInt(metricsPortFlag.Name)
|
||||
address := fmt.Sprintf("%s:%d", metricsAddr, metricsPort)
|
||||
log.Info("Enabling stand-alone metrics HTTP endpoint", "addr", address)
|
||||
exp.Setup(address)
|
||||
}
|
||||
|
||||
// pprof server
|
||||
if ctx.GlobalBool(pprofFlag.Name) {
|
||||
listenHost := ctx.GlobalString(pprofAddrFlag.Name)
|
||||
if ctx.GlobalIsSet(legacyPprofAddrFlag.Name) && !ctx.GlobalIsSet(pprofAddrFlag.Name) {
|
||||
listenHost = ctx.GlobalString(legacyPprofAddrFlag.Name)
|
||||
log.Warn("The flag --pprofaddr is deprecated and will be removed in the future, please use --pprof.addr")
|
||||
}
|
||||
|
||||
port := ctx.GlobalInt(pprofPortFlag.Name)
|
||||
if ctx.GlobalIsSet(legacyPprofPortFlag.Name) && !ctx.GlobalIsSet(pprofPortFlag.Name) {
|
||||
port = ctx.GlobalInt(legacyPprofPortFlag.Name)
|
||||
log.Warn("The flag --pprofport is deprecated and will be removed in the future, please use --pprof.port")
|
||||
}
|
||||
|
||||
address := fmt.Sprintf("%s:%d", listenHost, port)
|
||||
if pprofEnabled {
|
||||
pprofHost := ctx.GlobalString(pprofAddrFlag.Name)
|
||||
pprofPort := ctx.GlobalInt(pprofPortFlag.Name)
|
||||
address := fmt.Sprintf("%s:%d", pprofHost, pprofPort)
|
||||
// This context value ("metrics.addr") represents the utils.MetricsHTTPFlag.Name.
|
||||
// It cannot be imported because it will cause a cyclical dependency.
|
||||
StartPProf(address, !ctx.GlobalIsSet("metrics.addr"))
|
||||
withMetrics := metrics.Enabled && metricsAddr == ""
|
||||
StartPProf(address, withMetrics)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user