From d2ec68d3e319d08f32dc0df4adf1fd7531d12217 Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Thu, 24 Mar 2022 16:05:36 +0100 Subject: [PATCH] feat(metrics): replace metrics port with address (breaking change) (#2382) --- Dockerfile.staging | 2 +- chain/dev/config.toml | 2 +- chain/dev/defaults.go | 4 +- chain/gssmr/config.toml | 2 +- chain/gssmr/defaults.go | 4 +- chain/kusama/config.toml | 2 +- chain/kusama/defaults.go | 4 +- chain/polkadot/config.toml | 2 +- cmd/gossamer/README.md | 4 +- cmd/gossamer/config.go | 8 +-- cmd/gossamer/config_test.go | 30 +++++------ cmd/gossamer/export.go | 14 +++--- cmd/gossamer/export_test.go | 2 +- cmd/gossamer/flags.go | 10 ++-- cmd/gossamer/utils.go | 2 +- devnet/alice.Dockerfile | 2 +- devnet/bob.Dockerfile | 1 + docs/docs/integrate/using-prometheus.md | 6 ++- dot/config.go | 66 ++++++++++++------------- dot/config/toml/config.go | 14 +++--- dot/node.go | 6 +-- tests/data/db/config.toml | 2 +- tests/utils/gossamer_utils.go | 12 ++--- 23 files changed, 101 insertions(+), 100 deletions(-) diff --git a/Dockerfile.staging b/Dockerfile.staging index 434649772d..5417939466 100644 --- a/Dockerfile.staging +++ b/Dockerfile.staging @@ -23,5 +23,5 @@ RUN go get ./... RUN go build github.com/ChainSafe/gossamer/cmd/gossamer RUN ["sh", "-c", "gossamer init --chain=${chain}"] -ENTRYPOINT ["sh", "-c", "service datadog-agent restart && gossamer --chain=${chain} --basepath=${basepath}/${chain} --publish-metrics --pprofserver --pprofaddress=\":6060\""] +ENTRYPOINT ["sh", "-c", "service datadog-agent restart && gossamer --chain=${chain} --basepath=${basepath}/${chain} --publish-metrics --metrics-address=\":9876\" --pprofserver --pprofaddress=\":6060\""] EXPOSE 7001 8546 8540 9876 6060 \ No newline at end of file diff --git a/chain/dev/config.toml b/chain/dev/config.toml index f7bdce58a4..4642424409 100644 --- a/chain/dev/config.toml +++ b/chain/dev/config.toml @@ -1,7 +1,7 @@ [global] basepath = "~/.gossamer/dev" log = "info" -metrics-port = 9876 +metrics-address = ":9876" [log] core = "" diff --git a/chain/dev/defaults.go b/chain/dev/defaults.go index 8c242f616f..eb6a172117 100644 --- a/chain/dev/defaults.go +++ b/chain/dev/defaults.go @@ -21,8 +21,8 @@ var ( // DefaultBasePath is the node base directory path DefaultBasePath = string("~/.gossamer/dev") - // DefaultMetricsPort is the metrics server port - DefaultMetricsPort = uint32(9876) + // DefaultMetricsAddress is the default metrics server listening address. + DefaultMetricsAddress = ":9876" // DefaultLvl is the default log level DefaultLvl = log.Info diff --git a/chain/gssmr/config.toml b/chain/gssmr/config.toml index e26c8cb37c..de3a040bcd 100644 --- a/chain/gssmr/config.toml +++ b/chain/gssmr/config.toml @@ -1,7 +1,7 @@ [global] basepath = "~/.gossamer/gssmr" log = "info" -metrics-port = 9876 +metrics-address = "localhost:9876" [log] core = "" diff --git a/chain/gssmr/defaults.go b/chain/gssmr/defaults.go index 806a86f5b9..061b8cd478 100644 --- a/chain/gssmr/defaults.go +++ b/chain/gssmr/defaults.go @@ -23,8 +23,8 @@ var ( // DefaultBasePath Default node base directory path DefaultBasePath = string("~/.gossamer/gssmr") - // DefaultMetricsPort is the metrics server port - DefaultMetricsPort = uint32(9876) + // DefaultMetricsAddress is the default metrics server listening address. + DefaultMetricsAddress = "localhost:9876" // DefaultLvl is the default log level DefaultLvl = log.Info diff --git a/chain/kusama/config.toml b/chain/kusama/config.toml index 6e7dfb88a1..3ce5a210ea 100644 --- a/chain/kusama/config.toml +++ b/chain/kusama/config.toml @@ -1,7 +1,7 @@ [global] basepath = "~/.gossamer/kusama" log = "info" -metrics-port = 9876 +metrics-address = "localhost:9876" [log] core = "" diff --git a/chain/kusama/defaults.go b/chain/kusama/defaults.go index f312ef7e9e..f5c7f2f52c 100644 --- a/chain/kusama/defaults.go +++ b/chain/kusama/defaults.go @@ -21,8 +21,8 @@ var ( // DefaultBasePath Default node base directory path DefaultBasePath = string("~/.gossamer/kusama") - // DefaultMetricsPort is the metrics server port - DefaultMetricsPort = uint32(9876) + // DefaultMetricsAddress is the default metrics server listening address. + DefaultMetricsAddress = "localhost:9876" // DefaultLvl is the default log level DefaultLvl = log.Info diff --git a/chain/polkadot/config.toml b/chain/polkadot/config.toml index 24271f884e..afdb693abc 100644 --- a/chain/polkadot/config.toml +++ b/chain/polkadot/config.toml @@ -1,7 +1,7 @@ [global] basepath = "~/.gossamer/polkadot" log = "info" -metrics-port = 9876 +metrics-address = "localhost:9876" [log] core = "" diff --git a/cmd/gossamer/README.md b/cmd/gossamer/README.md index f71ac24f2f..ec6cba7d00 100644 --- a/cmd/gossamer/README.md +++ b/cmd/gossamer/README.md @@ -188,7 +188,7 @@ defined in [lib/runtime/wasmer/exports.go](../../lib/runtime/wasmer/exports.go). Gossamer publishes telemetry data and also includes an embedded Prometheus server that reports metrics. The metrics capabilities are defined in the [dot/metrics](../../dot/metrics) package and build on [the metrics library that is included with Go Ethereum](https://github.com/ethereum/go-ethereum/blob/master/metrics/README.md). -The default port for Prometheus metrics is 9090, and Gossamer allows the user to configure this parameter with the -`--metrics-port` command-line parameter. The Gossamer telemetry server publishes telemetry data that is compatible with +The default listening address for Prometheus metrics is `localhost:9090`, and Gossamer allows the user to configure this parameter with the +`--metrics-address` command-line parameter. The Gossamer telemetry server publishes telemetry data that is compatible with [Polkadot Telemetry](https://github.com/paritytech/substrate-telemetry) and [its helpful UI](https://telemetry.polkadot.io/). diff --git a/cmd/gossamer/config.go b/cmd/gossamer/config.go index 21744cd718..14ae28f9cf 100644 --- a/cmd/gossamer/config.go +++ b/cmd/gossamer/config.go @@ -458,7 +458,7 @@ func setDotGlobalConfigFromToml(tomlCfg *ctoml.Config, cfg *dot.GlobalConfig) { } } - cfg.MetricsPort = tomlCfg.Global.MetricsPort + cfg.MetricsAddress = tomlCfg.Global.MetricsAddress cfg.RetainBlocks = tomlCfg.Global.RetainBlocks cfg.Pruning = pruner.Mode(tomlCfg.Global.Pruning) @@ -485,9 +485,9 @@ func setDotGlobalConfigFromFlags(ctx *cli.Context, cfg *dot.GlobalConfig) error cfg.PublishMetrics = ctx.Bool("publish-metrics") - // check --metrics-port flag and update node configuration - if metricsPort := ctx.GlobalUint(MetricsPortFlag.Name); metricsPort != 0 { - cfg.MetricsPort = uint32(metricsPort) + // check --metrics-address flag and update node configuration + if metricsAddress := ctx.GlobalString(MetricsAddressFlag.Name); metricsAddress != "" { + cfg.MetricsAddress = metricsAddress } cfg.RetainBlocks = ctx.Int64(RetainBlockNumberFlag.Name) diff --git a/cmd/gossamer/config_test.go b/cmd/gossamer/config_test.go index 9d3633b1e2..c3d6e6aace 100644 --- a/cmd/gossamer/config_test.go +++ b/cmd/gossamer/config_test.go @@ -136,7 +136,7 @@ func TestGlobalConfigFromFlags(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, }, }, { @@ -149,7 +149,7 @@ func TestGlobalConfigFromFlags(t *testing.T) { BasePath: dot.KusamaConfig().Global.BasePath, LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, }, }, { @@ -162,7 +162,7 @@ func TestGlobalConfigFromFlags(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, }, }, { @@ -175,7 +175,7 @@ func TestGlobalConfigFromFlags(t *testing.T) { BasePath: "test_basepath", LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, }, }, { @@ -188,7 +188,7 @@ func TestGlobalConfigFromFlags(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, }, }, { @@ -201,20 +201,20 @@ func TestGlobalConfigFromFlags(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: log.Info, PublishMetrics: true, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, }, }, { - "Test gossamer --metrics-port", - []string{"config", "metrics-port", "name"}, - []interface{}{testCfgFile.Name(), "9871", testCfg.Global.Name}, + "Test gossamer --metrics-address", + []string{"config", "metrics-address", "name"}, + []interface{}{testCfgFile.Name(), ":9871", testCfg.Global.Name}, dot.GlobalConfig{ Name: testCfg.Global.Name, ID: testCfg.Global.ID, BasePath: testCfg.Global.BasePath, LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: uint32(9871), + MetricsAddress: ":9871", }, }, { @@ -227,7 +227,7 @@ func TestGlobalConfigFromFlags(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, NoTelemetry: true, }, }, @@ -245,7 +245,7 @@ func TestGlobalConfigFromFlags(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, NoTelemetry: false, TelemetryURLs: []genesis.TelemetryEndpoint{ {Endpoint: "ws://localhost:8001/submit", Verbosity: 0}, @@ -783,7 +783,7 @@ func TestUpdateConfigFromGenesisJSON(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: testCfg.Global.LogLvl, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, TelemetryURLs: testCfg.Global.TelemetryURLs, }, Log: dot.LogConfig{ @@ -837,7 +837,7 @@ func TestUpdateConfigFromGenesisJSON_Default(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: testCfg.Global.LogLvl, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, TelemetryURLs: testCfg.Global.TelemetryURLs, }, Log: dot.LogConfig{ @@ -887,7 +887,7 @@ func TestUpdateConfigFromGenesisData(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: testCfg.Global.LogLvl, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, TelemetryURLs: testCfg.Global.TelemetryURLs, }, Log: dot.LogConfig{ diff --git a/cmd/gossamer/export.go b/cmd/gossamer/export.go index c99c7b89dd..4c845d7601 100644 --- a/cmd/gossamer/export.go +++ b/cmd/gossamer/export.go @@ -67,13 +67,13 @@ func dotConfigToToml(dcfg *dot.Config) *ctoml.Config { } cfg.Global = ctoml.GlobalConfig{ - Name: dcfg.Global.Name, - ID: dcfg.Global.ID, - BasePath: dcfg.Global.BasePath, - LogLvl: dcfg.Global.LogLvl.String(), - MetricsPort: dcfg.Global.MetricsPort, - RetainBlocks: dcfg.Global.RetainBlocks, - Pruning: string(dcfg.Global.Pruning), + Name: dcfg.Global.Name, + ID: dcfg.Global.ID, + BasePath: dcfg.Global.BasePath, + LogLvl: dcfg.Global.LogLvl.String(), + MetricsAddress: dcfg.Global.MetricsAddress, + RetainBlocks: dcfg.Global.RetainBlocks, + Pruning: string(dcfg.Global.Pruning), } cfg.Log = ctoml.LogConfig{ diff --git a/cmd/gossamer/export_test.go b/cmd/gossamer/export_test.go index 78a6f1931b..5f36e045aa 100644 --- a/cmd/gossamer/export_test.go +++ b/cmd/gossamer/export_test.go @@ -47,7 +47,7 @@ func TestExportCommand(t *testing.T) { BasePath: testCfg.Global.BasePath, LogLvl: log.Info, PublishMetrics: testCfg.Global.PublishMetrics, - MetricsPort: testCfg.Global.MetricsPort, + MetricsAddress: testCfg.Global.MetricsAddress, }, Log: dot.LogConfig{ CoreLvl: log.Info, diff --git a/cmd/gossamer/flags.go b/cmd/gossamer/flags.go index 58fe0d1ea2..6222bcd224 100644 --- a/cmd/gossamer/flags.go +++ b/cmd/gossamer/flags.go @@ -128,10 +128,10 @@ var ( Usage: "Publish node metrics", } - // MetricsPortFlag set metric listen port - MetricsPortFlag = cli.StringFlag{ - Name: "metrics-port", - Usage: "Set metric listening port ", + // MetricsAddressFlag sets the metric server listening address + MetricsAddressFlag = cli.StringFlag{ + Name: "metrics-address", + Usage: "Set the metric server listening address", } // NoTelemetryFlag stops publishing telemetry to default defined in genesis.json @@ -442,7 +442,7 @@ var ( // metrics flag PublishMetricsFlag, - MetricsPortFlag, + MetricsAddressFlag, // telemetry flags NoTelemetryFlag, diff --git a/cmd/gossamer/utils.go b/cmd/gossamer/utils.go index 8c287b229f..51acc3fb0e 100644 --- a/cmd/gossamer/utils.go +++ b/cmd/gossamer/utils.go @@ -76,7 +76,7 @@ func newTestConfig(t *testing.T) *dot.Config { BasePath: dir, LogLvl: log.Info, PublishMetrics: dot.GssmrConfig().Global.PublishMetrics, - MetricsPort: dot.GssmrConfig().Global.MetricsPort, + MetricsAddress: dot.GssmrConfig().Global.MetricsAddress, RetainBlocks: dot.GssmrConfig().Global.RetainBlocks, Pruning: dot.GssmrConfig().Global.Pruning, TelemetryURLs: dot.GssmrConfig().Global.TelemetryURLs, diff --git a/devnet/alice.Dockerfile b/devnet/alice.Dockerfile index 5b144ea29a..39a0b352c8 100644 --- a/devnet/alice.Dockerfile +++ b/devnet/alice.Dockerfile @@ -38,6 +38,6 @@ RUN go run cmd/update-dd-agent-confd/main.go -n=${METRICS_NAMESPACE} -t=key:alic WORKDIR /gossamer -ENTRYPOINT service datadog-agent start && gossamer --key=alice --babe-lead --publish-metrics --rpc --rpc-external=true --pubdns=alice --port 7001 +ENTRYPOINT service datadog-agent start && gossamer --key=alice --babe-lead --publish-metrics --metrics-address=":9876" --rpc --rpc-external=true --pubdns=alice --port 7001 EXPOSE 7001/tcp 8545/tcp 8546/tcp 8540/tcp 9876/tcp 6060/tcp diff --git a/devnet/bob.Dockerfile b/devnet/bob.Dockerfile index b5b7e4b2fe..f391197dcc 100644 --- a/devnet/bob.Dockerfile +++ b/devnet/bob.Dockerfile @@ -42,6 +42,7 @@ WORKDIR /gossamer ENTRYPOINT service datadog-agent start && gossamer --key=${key} \ --bootnodes=/dns/alice/tcp/7001/p2p/12D3KooWMER5iow67nScpWeVqEiRRx59PJ3xMMAYPTACYPRQbbWU \ --publish-metrics \ + --metrics-address=":9876" \ --rpc \ --port 7001 \ --pubdns=${key} diff --git a/docs/docs/integrate/using-prometheus.md b/docs/docs/integrate/using-prometheus.md index 814c81f917..256c54d691 100644 --- a/docs/docs/integrate/using-prometheus.md +++ b/docs/docs/integrate/using-prometheus.md @@ -22,8 +22,10 @@ the above command will starts the Prometheus service on `0.0.0.0:9090`. ### Prometheus -Actually the Prometheus service reads a file `prometheus.yml` placed in the root level project folder, this file contains the definitions that Prometheus needs to collect the metrics. +Actually the Prometheus service reads a file `prometheus.yml` placed in the root level project folder, this file contains the definitions that Prometheus needs to collect the metrics. Linux: In the **job_name == gossamer** the **targets** property should be `[localhost:9876]` -To publish metrics from the node use the flag **--publish-metrics**; i.e, `./bin/gossamer --chain {chain} --key {key} --publish-metrics` \ No newline at end of file +To publish metrics from the node use the flag `--publish-metrics`; i.e, `./bin/gossamer --chain {chain} --key {key} --publish-metrics`. + +By default, the Prometheus server listens on `localhost:9876`, which you can change with `--metrics-address`. To listen on all interfaces, you can use `--metrics-address=":9876"`. diff --git a/dot/config.go b/dot/config.go index ee88d85240..a9e1b633df 100644 --- a/dot/config.go +++ b/dot/config.go @@ -43,7 +43,7 @@ type GlobalConfig struct { BasePath string LogLvl log.Level PublishMetrics bool - MetricsPort uint32 + MetricsAddress string NoTelemetry bool TelemetryURLs []genesis.TelemetryEndpoint RetainBlocks int64 @@ -184,14 +184,14 @@ func (p PprofConfig) String() string { func GssmrConfig() *Config { return &Config{ Global: GlobalConfig{ - Name: gssmr.DefaultName, - ID: gssmr.DefaultID, - BasePath: gssmr.DefaultBasePath, - LogLvl: gssmr.DefaultLvl, - MetricsPort: gssmr.DefaultMetricsPort, - RetainBlocks: gssmr.DefaultRetainBlocks, - Pruning: pruner.Mode(gssmr.DefaultPruningMode), - TelemetryURLs: gssmr.DefaultTelemetryURLs, + Name: gssmr.DefaultName, + ID: gssmr.DefaultID, + BasePath: gssmr.DefaultBasePath, + LogLvl: gssmr.DefaultLvl, + MetricsAddress: gssmr.DefaultMetricsAddress, + RetainBlocks: gssmr.DefaultRetainBlocks, + Pruning: pruner.Mode(gssmr.DefaultPruningMode), + TelemetryURLs: gssmr.DefaultTelemetryURLs, }, Log: LogConfig{ CoreLvl: gssmr.DefaultLvl, @@ -248,14 +248,14 @@ func GssmrConfig() *Config { func KusamaConfig() *Config { return &Config{ Global: GlobalConfig{ - Name: kusama.DefaultName, - ID: kusama.DefaultID, - BasePath: kusama.DefaultBasePath, - LogLvl: kusama.DefaultLvl, - MetricsPort: kusama.DefaultMetricsPort, - RetainBlocks: gssmr.DefaultRetainBlocks, - Pruning: pruner.Mode(gssmr.DefaultPruningMode), - TelemetryURLs: kusama.DefaultTelemetryURLs, + Name: kusama.DefaultName, + ID: kusama.DefaultID, + BasePath: kusama.DefaultBasePath, + LogLvl: kusama.DefaultLvl, + MetricsAddress: kusama.DefaultMetricsAddress, + RetainBlocks: gssmr.DefaultRetainBlocks, + Pruning: pruner.Mode(gssmr.DefaultPruningMode), + TelemetryURLs: kusama.DefaultTelemetryURLs, }, Log: LogConfig{ CoreLvl: kusama.DefaultLvl, @@ -306,14 +306,14 @@ func KusamaConfig() *Config { func PolkadotConfig() *Config { return &Config{ Global: GlobalConfig{ - Name: polkadot.DefaultName, - ID: polkadot.DefaultID, - BasePath: polkadot.DefaultBasePath, - LogLvl: polkadot.DefaultLvl, - RetainBlocks: gssmr.DefaultRetainBlocks, - Pruning: pruner.Mode(gssmr.DefaultPruningMode), - MetricsPort: gssmr.DefaultMetricsPort, - TelemetryURLs: polkadot.DefaultTelemetryURLs, + Name: polkadot.DefaultName, + ID: polkadot.DefaultID, + BasePath: polkadot.DefaultBasePath, + LogLvl: polkadot.DefaultLvl, + RetainBlocks: gssmr.DefaultRetainBlocks, + Pruning: pruner.Mode(gssmr.DefaultPruningMode), + MetricsAddress: gssmr.DefaultMetricsAddress, + TelemetryURLs: polkadot.DefaultTelemetryURLs, }, Log: LogConfig{ CoreLvl: polkadot.DefaultLvl, @@ -364,14 +364,14 @@ func PolkadotConfig() *Config { func DevConfig() *Config { return &Config{ Global: GlobalConfig{ - Name: dev.DefaultName, - ID: dev.DefaultID, - BasePath: dev.DefaultBasePath, - LogLvl: dev.DefaultLvl, - MetricsPort: dev.DefaultMetricsPort, - RetainBlocks: dev.DefaultRetainBlocks, - Pruning: pruner.Mode(dev.DefaultPruningMode), - TelemetryURLs: dev.DefaultTelemetryURLs, + Name: dev.DefaultName, + ID: dev.DefaultID, + BasePath: dev.DefaultBasePath, + LogLvl: dev.DefaultLvl, + MetricsAddress: dev.DefaultMetricsAddress, + RetainBlocks: dev.DefaultRetainBlocks, + Pruning: pruner.Mode(dev.DefaultPruningMode), + TelemetryURLs: dev.DefaultTelemetryURLs, }, Log: LogConfig{ CoreLvl: dev.DefaultLvl, diff --git a/dot/config/toml/config.go b/dot/config/toml/config.go index e353eed573..72e5012bf2 100644 --- a/dot/config/toml/config.go +++ b/dot/config/toml/config.go @@ -17,13 +17,13 @@ type Config struct { // GlobalConfig is to marshal/unmarshal toml global config vars type GlobalConfig struct { - Name string `toml:"name,omitempty"` - ID string `toml:"id,omitempty"` - BasePath string `toml:"basepath,omitempty"` - LogLvl string `toml:"log,omitempty"` - MetricsPort uint32 `toml:"metrics-port,omitempty"` - RetainBlocks int64 `toml:"retain-blocks,omitempty"` - Pruning string `toml:"pruning,omitempty"` + Name string `toml:"name,omitempty"` + ID string `toml:"id,omitempty"` + BasePath string `toml:"basepath,omitempty"` + LogLvl string `toml:"log,omitempty"` + MetricsAddress string `toml:"metrics-address,omitempty"` + RetainBlocks int64 `toml:"retain-blocks,omitempty"` + Pruning string `toml:"pruning,omitempty"` } // LogConfig represents the log levels for individual packages diff --git a/dot/node.go b/dot/node.go index 0ac8e680ec..0d3a626087 100644 --- a/dot/node.go +++ b/dot/node.go @@ -354,10 +354,8 @@ func NewNode(cfg *Config, ks *keystore.GlobalKeystore) (*Node, error) { } if cfg.Global.PublishMetrics { - address := fmt.Sprintf("%s:%d", cfg.RPC.Host, cfg.Global.MetricsPort) - logger.Info("Enabling stand-alone metrics HTTP endpoint at address " + address) - node.metricsServer = metrics.NewServer(address) - err := node.metricsServer.Start(address) + node.metricsServer = metrics.NewServer(cfg.Global.MetricsAddress) + err := node.metricsServer.Start(cfg.Global.MetricsAddress) if err != nil { return nil, fmt.Errorf("cannot start metrics server: %w", err) } diff --git a/tests/data/db/config.toml b/tests/data/db/config.toml index 841fa35b2b..2bc0192f49 100644 --- a/tests/data/db/config.toml +++ b/tests/data/db/config.toml @@ -1,7 +1,7 @@ [global] basepath = "../../tests/data/db" log = "info" -metrics-port = 9876 +metrics-address = "localhost:9876" [log] core = "" diff --git a/tests/utils/gossamer_utils.go b/tests/utils/gossamer_utils.go index 4ec93a4a1c..ec36d3009d 100644 --- a/tests/utils/gossamer_utils.go +++ b/tests/utils/gossamer_utils.go @@ -427,12 +427,12 @@ func GenerateGenesisSixAuth(t *testing.T) { func generateDefaultConfig() *ctoml.Config { return &ctoml.Config{ Global: ctoml.GlobalConfig{ - Name: "Gossamer", - ID: "gssmr", - LogLvl: "crit", - MetricsPort: 9876, - RetainBlocks: 256, - Pruning: "archive", + Name: "Gossamer", + ID: "gssmr", + LogLvl: "crit", + MetricsAddress: "localhost:9876", + RetainBlocks: 256, + Pruning: "archive", }, Log: ctoml.LogConfig{ CoreLvl: "info",