Skip to content

main,utils,exp: enable stand-alone metrics server from pprof#135

Merged
meowsbits merged 1 commit intomasterfrom
feat/metrics-http-standalone-from-pprof
Jul 4, 2020
Merged

main,utils,exp: enable stand-alone metrics server from pprof#135
meowsbits merged 1 commit intomasterfrom
feat/metrics-http-standalone-from-pprof

Conversation

@meowsbits
Copy link
Copy Markdown
Contributor

@meowsbits meowsbits commented Jul 2, 2020

ExpVar and Prometheus metrics endpoints were bundled and dependent with --pprof.

Since --pprof exposes sensitive/vulnerable behavior, this change allows the user the configure a metrics endpoint independent of the pprof endpoint.

Adds the following flags:

	// MetricsHTTPFlag defines the endpoint for a stand-alone metrics HTTP endpoint.
	// Since the pprof service enables sensitive/vulnerable behavior, this allows a user
	// to enable a public-OK metrics endpoint without having to worry about ALSO exposing
	// other profiling behavior or information.
	MetricsHTTPFlag = cli.StringFlag{
		Name: "metrics.addr",
		Usage: "Enable stand-alone metrics HTTP server listening interface",
		Value: "127.0.0.1",
	}
	MetricsPortFlag = cli.IntFlag{
		Name: "metrics.port",
		Usage: "Metrics HTTP server listening port",
		Value: 6060,
	}

Use:

# Keeps previous behavior; exposes 
# - http://127.0.0.1:6060/debug/pprof 
# - http://127.0.0.1:6060/debug/metrics
# - http://127.0.0.1:6060/debug/metrics/prometheus
> geth --pprof --metrics

# Keeps previous behavior; exposes 
# - http://0.0.0.0:8080/debug/pprof 
# - http://0.0.0.0:8080/debug/metrics
# - http://0.0.0.0:8080/debug/metrics/prometheus
> geth --pprof --pprof.addr=0.0.0.0 --pprof.port=8080 --metrics

# Enables separated behavior; exposes 
# - http://127.0.0.1:6060/debug/pprof 
# - http://0.0.0.0:8080/debug/metrics
# - http://0.0.0.0:8080/debug/metrics/prometheus
> geth --pprof [--pprof.addr=127.0.0.1 (default)] --metrics --metrics.addr=0.0.0.0 --metrics.port=8080

# Enables stand-alone behavior; exposes 
# - http://0.0.0.0:8080/debug/metrics
# - http://0.0.0.0:8080/debug/metrics/prometheus
> geth --metrics --metrics.addr=0.0.0.0 --metrics.port=8080

# Colliding endpoints will cause the metrics endpoint to fail,and an ERROR message to be logged
> geth --pprof --metrics --metrics.addr=0.0.0.0
INFO [07-02|10:45:49.796] Starting pprof server                    addr=http://127.0.0.1:6060/debug/pprof
INFO [07-02|10:45:49.796] Starting Geth on Ethereum mainnet...
INFO [07-02|10:45:49.796] Bumping default cache on mainnet         provided=1024 updated=4096
INFO [07-02|10:45:49.796] Enabling metrics collection
INFO [07-02|10:45:49.797] Enabling stand-alone metrics HTTP endpoint address=0.0.0.0:6060
INFO [07-02|10:45:49.797] Starting metrics server                  addr=http://0.0.0.0:6060/debug/metrics
ERROR[07-02|10:45:49.797] Failure in running metrics server        err="listen tcp 0.0.0.0:6060: bind: address already in use"

/debug/metrics and /debug/metrics/prometheus
were bundled and dependent with --pprof.

Since --pprof exposes sensitive/vulnerable
behavior, this allows the user the configure a
public-safe metrics endpoint apart from the pprof
endpoint.

Signed-off-by: meows <b5c6@protonmail.com>
@meowsbits meowsbits force-pushed the feat/metrics-http-standalone-from-pprof branch from db9a599 to 4bdd7b0 Compare July 2, 2020 15:39
@meowsbits meowsbits merged commit 4bdd7b0 into master Jul 4, 2020
@meowsbits meowsbits deleted the feat/metrics-http-standalone-from-pprof branch July 4, 2020 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant