Skip to content

Commit

Permalink
Change prometheus port for different parts of Prysm (#5504)
Browse files Browse the repository at this point in the history
* Change prometheus flag from default 8080 and sort flags
* Merge branch 'master' of https://github.com/prysmaticlabs/prysm into change-prometheus-port
* Fix build
* Merge branch 'master' of https://github.com/prysmaticlabs/prysm into change-prometheus-port
* Merge branch 'master' into change-prometheus-port
  • Loading branch information
0xKiwi authored Apr 19, 2020
1 parent f2d88ea commit dee3f02
Show file tree
Hide file tree
Showing 13 changed files with 85 additions and 68 deletions.
6 changes: 6 additions & 0 deletions beacon-chain/flags/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ var (
Usage: "Max number of items returned per page in RPC responses for paginated endpoints.",
Value: 500,
}
// MonitoringPortFlag defines the http port used to serve prometheus metrics.
MonitoringPortFlag = &cli.Int64Flag{
Name: "monitoring-port",
Usage: "Port used to listening and respond metrics for prometheus.",
Value: 8080,
}
// CertFlag defines a flag for the node's TLS certificate.
CertFlag = &cli.StringFlag{
Name: "tls-cert",
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ var appFlags = []cli.Flag{
cmd.TracingProcessNameFlag,
cmd.TracingEndpointFlag,
cmd.TraceSampleFractionFlag,
cmd.MonitoringPortFlag,
flags.MonitoringPortFlag,
cmd.DisableMonitoringFlag,
cmd.ClearDB,
cmd.ForceClearDB,
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ func (b *BeaconNode) registerPrometheusService(ctx *cli.Context) error {
additionalHandlers = append(additionalHandlers, prometheus.Handler{Path: "/tree", Handler: c.TreeHandler})

service := prometheus.NewPrometheusService(
fmt.Sprintf(":%d", ctx.Int64(cmd.MonitoringPortFlag.Name)),
fmt.Sprintf(":%d", ctx.Int64(flags.MonitoringPortFlag.Name)),
b.services,
additionalHandlers...,
)
Expand Down
2 changes: 1 addition & 1 deletion beacon-chain/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var appHelpFlagGroups = []flagGroup{
cmd.TracingProcessNameFlag,
cmd.TracingEndpointFlag,
cmd.TraceSampleFractionFlag,
cmd.MonitoringPortFlag,
flags.MonitoringPortFlag,
cmd.DisableMonitoringFlag,
cmd.MaxGoroutines,
cmd.ForceClearDB,
Expand Down
6 changes: 0 additions & 6 deletions shared/cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ var (
Name: "disable-monitoring",
Usage: "Disable monitoring service.",
}
// MonitoringPortFlag defines the http port used to serve prometheus metrics.
MonitoringPortFlag = &cli.Int64Flag{
Name: "monitoring-port",
Usage: "Port used to listening and respond metrics for prometheus.",
Value: 8080,
}
// NoDiscovery specifies whether we are running a local network and have no need for connecting
// to the bootstrap nodes in the cloud
NoDiscovery = &cli.BoolFlag{
Expand Down
46 changes: 26 additions & 20 deletions slasher/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,6 @@ import (
)

var (
// CertFlag defines a flag for the node's TLS certificate.
CertFlag = &cli.StringFlag{
Name: "tls-cert",
Usage: "Certificate for secure gRPC. Pass this and the tls-key flag in order to use gRPC securely.",
}
// RPCPort defines a slasher node RPC port to open.
RPCPort = &cli.IntFlag{
Name: "rpc-port",
Usage: "RPC port exposed by the slasher",
Value: 5000,
}
// KeyFlag defines a flag for the node's TLS key.
KeyFlag = &cli.StringFlag{
Name: "tls-key",
Usage: "Key for secure gRPC. Pass this and the tls-cert flag in order to use gRPC securely.",
}
// BeaconCertFlag defines a flag for the beacon api certificate.
BeaconCertFlag = &cli.StringFlag{
Name: "beacon-tls-cert",
Expand All @@ -32,14 +16,36 @@ var (
Usage: "Beacon node RPC provider endpoint",
Value: "localhost:4000",
}
// UseSpanCacheFlag enables the slasher to use span cache.
UseSpanCacheFlag = &cli.BoolFlag{
Name: "span-map-cache",
Usage: "Enable span map cache",
// CertFlag defines a flag for the node's TLS certificate.
CertFlag = &cli.StringFlag{
Name: "tls-cert",
Usage: "Certificate for secure gRPC. Pass this and the tls-key flag in order to use gRPC securely.",
}
// KeyFlag defines a flag for the node's TLS key.
KeyFlag = &cli.StringFlag{
Name: "tls-key",
Usage: "Key for secure gRPC. Pass this and the tls-cert flag in order to use gRPC securely.",
}
// MonitoringPortFlag defines the http port used to serve prometheus metrics.
MonitoringPortFlag = &cli.Int64Flag{
Name: "monitoring-port",
Usage: "Port used to listening and respond metrics for prometheus.",
Value: 8082,
}
// RPCPort defines a slasher node RPC port to open.
RPCPort = &cli.IntFlag{
Name: "rpc-port",
Usage: "RPC port exposed by the slasher",
Value: 5000,
}
// RebuildSpanMapsFlag iterate through all indexed attestations in db and update all validators span maps from scratch.
RebuildSpanMapsFlag = &cli.BoolFlag{
Name: "rebuild-span-maps",
Usage: "Rebuild span maps from indexed attestations in db",
}
// UseSpanCacheFlag enables the slasher to use span cache.
UseSpanCacheFlag = &cli.BoolFlag{
Name: "span-map-cache",
Usage: "Enable span map cache",
}
)
2 changes: 1 addition & 1 deletion slasher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var appFlags = []cli.Flag{
cmd.TracingEndpointFlag,
cmd.TraceSampleFractionFlag,
cmd.BootstrapNode,
cmd.MonitoringPortFlag,
flags.MonitoringPortFlag,
cmd.LogFileName,
cmd.LogFormat,
cmd.ClearDB,
Expand Down
2 changes: 1 addition & 1 deletion slasher/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (s *SlasherNode) Close() {

func (s *SlasherNode) registerPrometheusService(ctx *cli.Context) error {
service := prometheus.NewPrometheusService(
fmt.Sprintf(":%d", ctx.Int64(cmd.MonitoringPortFlag.Name)),
fmt.Sprintf(":%d", ctx.Int64(flags.MonitoringPortFlag.Name)),
s.services,
)
logrus.AddHook(prometheus.NewLogrusCollector())
Expand Down
2 changes: 1 addition & 1 deletion slasher/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ var appHelpFlagGroups = []flagGroup{
cmd.TracingEndpointFlag,
cmd.TraceSampleFractionFlag,
cmd.BootstrapNode,
cmd.MonitoringPortFlag,
flags.MonitoringPortFlag,
cmd.LogFormat,
cmd.LogFileName,
cmd.ForceClearDB,
Expand Down
77 changes: 44 additions & 33 deletions validator/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
)

var (
// AccountMetricsFlag defines the graffiti value included in proposed blocks, default false.
AccountMetricsFlag = &cli.BoolFlag{
Name: "enable-account-metrics",
Usage: "Enable prometheus metrics for validator accounts",
}
// BeaconRPCProviderFlag defines a beacon node RPC endpoint.
BeaconRPCProviderFlag = &cli.StringFlag{
Name: "beacon-rpc-provider",
Expand All @@ -16,35 +21,6 @@ var (
Name: "tls-cert",
Usage: "Certificate for secure gRPC. Pass this and the tls-key flag in order to use gRPC securely.",
}
// KeystorePathFlag defines the location of the keystore directory for a validator's account.
KeystorePathFlag = &cli.StringFlag{
Name: "keystore-path",
Usage: "Path to the desired keystore directory",
}
// UnencryptedKeysFlag specifies a file path of a JSON file of unencrypted validator keys as an
// alternative from launching the validator client from decrypting a keystore directory.
UnencryptedKeysFlag = &cli.StringFlag{
Name: "unencrypted-keys",
Usage: "Filepath to a JSON file of unencrypted validator keys for easier launching of the validator client",
Value: "",
}
// KeyManager specifies the key manager to use.
KeyManager = &cli.StringFlag{
Name: "keymanager",
Usage: "The keymanger to use (unencrypted, interop, keystore, wallet)",
Value: "",
}
// KeyManagerOpts specifies the key manager options.
KeyManagerOpts = &cli.StringFlag{
Name: "keymanageropts",
Usage: "The options for the keymanger, either a JSON string or path to same",
Value: "",
}
// PasswordFlag defines the password value for storing and retrieving validator private keys from the keystore.
PasswordFlag = &cli.StringFlag{
Name: "password",
Usage: "String value of the password for your validator private keys",
}
// DisablePenaltyRewardLogFlag defines the ability to not log reward/penalty information during deployment
DisablePenaltyRewardLogFlag = &cli.BoolFlag{
Name: "disable-rewards-penalties-logging",
Expand Down Expand Up @@ -72,9 +48,44 @@ var (
Usage: "A comma separated list of key value pairs to pass as gRPC headers for all gRPC " +
"calls. Example: --grpc-headers=key=value",
}
// AccountMetricsFlag defines the graffiti value included in proposed blocks, default false.
AccountMetricsFlag = &cli.BoolFlag{
Name: "enable-account-metrics",
Usage: "Enable prometheus metrics for validator accounts",
// KeyManager specifies the key manager to use.
KeyManager = &cli.StringFlag{
Name: "keymanager",
Usage: "The keymanger to use (unencrypted, interop, keystore, wallet)",
Value: "",
}
// KeyManagerOpts specifies the key manager options.
KeyManagerOpts = &cli.StringFlag{
Name: "keymanageropts",
Usage: "The options for the keymanger, either a JSON string or path to same",
Value: "",
}
// KeystorePathFlag defines the location of the keystore directory for a validator's account.
KeystorePathFlag = &cli.StringFlag{
Name: "keystore-path",
Usage: "Path to the desired keystore directory",
}
// MonitoringPortFlag defines the http port used to serve prometheus metrics.
MonitoringPortFlag = &cli.Int64Flag{
Name: "monitoring-port",
Usage: "Port used to listening and respond metrics for prometheus.",
Value: 8081,
}
// NoCustomConfigFlag determines whether to launch a beacon chain using real parameters or demo parameters.
NoCustomConfigFlag = &cli.BoolFlag{
Name: "no-custom-config",
Usage: "Run the beacon chain with the real parameters from phase 0.",
}
// PasswordFlag defines the password value for storing and retrieving validator private keys from the keystore.
PasswordFlag = &cli.StringFlag{
Name: "password",
Usage: "String value of the password for your validator private keys",
}
// UnencryptedKeysFlag specifies a file path of a JSON file of unencrypted validator keys as an
// alternative from launching the validator client from decrypting a keystore directory.
UnencryptedKeysFlag = &cli.StringFlag{
Name: "unencrypted-keys",
Usage: "Filepath to a JSON file of unencrypted validator keys for easier launching of the validator client",
Value: "",
}
)
2 changes: 1 addition & 1 deletion validator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var appFlags = []cli.Flag{
cmd.TracingProcessNameFlag,
cmd.TracingEndpointFlag,
cmd.TraceSampleFractionFlag,
cmd.MonitoringPortFlag,
flags.MonitoringPortFlag,
cmd.LogFormat,
debug.PProfFlag,
debug.PProfAddrFlag,
Expand Down
2 changes: 1 addition & 1 deletion validator/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s *ValidatorClient) Close() {

func (s *ValidatorClient) registerPrometheusService(ctx *cli.Context) error {
service := prometheus.NewPrometheusService(
fmt.Sprintf(":%d", ctx.Int64(cmd.MonitoringPortFlag.Name)),
fmt.Sprintf(":%d", ctx.Int64(flags.MonitoringPortFlag.Name)),
s.services,
)
logrus.AddHook(prometheus.NewLogrusCollector())
Expand Down
2 changes: 1 addition & 1 deletion validator/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var appHelpFlagGroups = []flagGroup{
cmd.TracingProcessNameFlag,
cmd.TracingEndpointFlag,
cmd.TraceSampleFractionFlag,
cmd.MonitoringPortFlag,
flags.MonitoringPortFlag,
cmd.LogFormat,
cmd.LogFileName,
cmd.ConfigFileFlag,
Expand Down

0 comments on commit dee3f02

Please sign in to comment.