From 3598d7fa860450c3d41ada2461465eb6cb43ca0d Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 22 Mar 2022 17:03:53 -0500 Subject: [PATCH] Pull block counts by default again since the underlying performance issue was resolved in chia Revert "Merge pull request #12 from Chia-Network/block-count-optional" This reverts commit 69b49863cdb23dd144d9a80bf683ed79301e6a0f, reversing changes made to ef0e3407d9c4a00bfe1c72efad7aa1f5796d2562. --- cmd/root.go | 5 ----- internal/metrics/fullnode.go | 13 ++----------- readme.md | 10 +--------- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index f022f6c..499334e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -30,9 +30,6 @@ func init() { var ( metricsPort int maxmindDBPath string - - // Optional Metrics - enableBlockCounts bool ) cobra.OnInitialize(initConfig) @@ -40,11 +37,9 @@ func init() { rootCmd.PersistentFlags().IntVar(&metricsPort, "metrics-port", 9914, "The port the metrics server binds to") rootCmd.PersistentFlags().StringVar(&maxmindDBPath, "maxmind-db-path", "", "Path to the maxmind database file") - rootCmd.PersistentFlags().BoolVar(&enableBlockCounts, "enable-block-counts", false, "Enables block count metrics. This tends to increase the reads on the disk, so is optional, and disabled by default.") viper.BindPFlag("metrics-port", rootCmd.PersistentFlags().Lookup("metrics-port")) viper.BindPFlag("maxmind-db-path", rootCmd.PersistentFlags().Lookup("maxmind-db-path")) - viper.BindPFlag("enable-block-counts", rootCmd.PersistentFlags().Lookup("enable-block-counts")) } // initConfig reads in config file and ENV variables if set. diff --git a/internal/metrics/fullnode.go b/internal/metrics/fullnode.go index f139dcd..f728913 100644 --- a/internal/metrics/fullnode.go +++ b/internal/metrics/fullnode.go @@ -8,7 +8,6 @@ import ( "github.com/chia-network/go-chia-libs/pkg/rpc" "github.com/chia-network/go-chia-libs/pkg/types" "github.com/prometheus/client_golang/prometheus" - "github.com/spf13/viper" wrappedPrometheus "github.com/chia-network/chia-exporter/internal/prometheus" "github.com/chia-network/chia-exporter/internal/utils" @@ -89,7 +88,7 @@ func (s *FullNodeServiceMetrics) InitMetrics() { func (s *FullNodeServiceMetrics) InitialData() { // Ask for some initial data so we dont have to wait as long utils.LogErr(s.metrics.client.FullNodeService.GetBlockchainState()) // Also calls get_connections once we get the response - s.RequestBlockCountMetrics() + utils.LogErr(s.metrics.client.FullNodeService.GetBlockCountMetrics()) } // Disconnected clears/unregisters metrics when the connection drops @@ -130,7 +129,7 @@ func (s *FullNodeServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) case "block": s.Block(resp) // Ask for block count metrics when we get a new block - s.RequestBlockCountMetrics() + utils.LogErr(s.metrics.client.FullNodeService.GetBlockCountMetrics()) case "get_connections": s.GetConnections(resp) case "get_block_count_metrics": @@ -140,14 +139,6 @@ func (s *FullNodeServiceMetrics) ReceiveResponse(resp *types.WebsocketResponse) } } -// RequestBlockCountMetrics Asks the full node for block count metrics -// This call can be expensive, so is optional -func (s *FullNodeServiceMetrics) RequestBlockCountMetrics() { - if viper.GetBool("enable-block-counts") { - utils.LogErr(s.metrics.client.FullNodeService.GetBlockCountMetrics()) - } -} - // GetBlockchainState handler for get_blockchain_state events func (s *FullNodeServiceMetrics) GetBlockchainState(resp *types.WebsocketResponse) { state := &types.WebsocketBlockchainState{} diff --git a/readme.md b/readme.md index 576a741..96435d1 100644 --- a/readme.md +++ b/readme.md @@ -22,14 +22,6 @@ To use a config file, create a new yaml file and place any configuration options metrics-port: 9914 ``` -## Optional Metrics - -There are a number of metrics that are opt-in due to external dependencies or because of a higher performance requirement to support them. - -### Block Count Metrics - -Counts of uncompact and compact blocks results in a database query that does a pretty big read from disk, so can be taxing on lower powered systems, and is disabled by default. To enable this metric, pass `--enable-block-counts` - -### Country Data +## Country Data When running alongside the crawler, the exporter can optionally export metrics indicating how many peers have been discovered in each country, based on IP address. To enable this functionality, you will need to download the MaxMind GeoLite2 Country database and provide the path to the MaxMind database to the exporter application. The path can be provided with a command line flag `--maxmind-db-path /path/to/GeoLite2-Country.mmdb`, an entry in the config yaml file `maxmind-db-path: /path/to/GeoLite2-Country.mmdb`, or an environment variable `CHIA_EXPORTER_MAXMIND_DB_PATH=/path/to/GeoLite2-Country.mmdb`. To gain access to the MaxMind DB, you can [register here](https://www.maxmind.com/en/geolite2/signup).