From 0650f4561b048db131635ff1fa4ebfd6bbd4452b Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Wed, 6 Apr 2022 21:33:37 -0500 Subject: [PATCH] Update readme for country + ASN db support. Change flag to include country in the name --- cmd/root.go | 4 ++-- internal/metrics/crawler.go | 2 +- readme.md | 9 +++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 54b5aba..4842b49 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -43,7 +43,7 @@ func init() { rootCmd.PersistentFlags().StringVar(&hostname, "hostname", "localhost", "The hostname to connect to") 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().StringVar(&maxmindDBPath, "maxmind-country-db-path", "", "Path to the maxmind country database file") rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "How verbose the logs should be. panic, fatal, error, warn, info, debug, trace") rootCmd.PersistentFlags().DurationVar(&requestTimeout, "rpc-timeout", 10*time.Second, "How long RPC requests will wait before timing out") rootCmd.PersistentFlags().BoolVar(&disableCentralHarvesterCollection, "disable-central-harvester-collection", false, "Disables collection of harvester information via the farmer. Useful for very large farms where this request is very expensive, or cases where chia-exporter is already installed on all harvesters") @@ -51,7 +51,7 @@ func init() { cobra.CheckErr(viper.BindPFlag("hostname", rootCmd.PersistentFlags().Lookup("hostname"))) cobra.CheckErr(viper.BindPFlag("metrics-port", rootCmd.PersistentFlags().Lookup("metrics-port"))) - cobra.CheckErr(viper.BindPFlag("maxmind-db-path", rootCmd.PersistentFlags().Lookup("maxmind-db-path"))) + cobra.CheckErr(viper.BindPFlag("maxmind-country-db-path", rootCmd.PersistentFlags().Lookup("maxmind-country-db-path"))) cobra.CheckErr(viper.BindPFlag("log-level", rootCmd.PersistentFlags().Lookup("log-level"))) cobra.CheckErr(viper.BindPFlag("rpc-timeout", rootCmd.PersistentFlags().Lookup("rpc-timeout"))) cobra.CheckErr(viper.BindPFlag("disable-central-harvester-collection", rootCmd.PersistentFlags().Lookup("disable-central-harvester-collection"))) diff --git a/internal/metrics/crawler.go b/internal/metrics/crawler.go index cf74e2a..66d85bb 100644 --- a/internal/metrics/crawler.go +++ b/internal/metrics/crawler.go @@ -66,7 +66,7 @@ func (s *CrawlerServiceMetrics) InitMetrics() { // If the DB is not present, ip/country mapping is skipped func (s *CrawlerServiceMetrics) initMaxmindDB() error { var err error - dbPath := viper.GetString("maxmind-db-path") + dbPath := viper.GetString("maxmind-country-db-path") if dbPath == "" { return nil } diff --git a/readme.md b/readme.md index 1664e49..0b2bb86 100644 --- a/readme.md +++ b/readme.md @@ -84,6 +84,11 @@ To use a config file, create a new yaml file and place any configuration options metrics-port: 9914 ``` -## Country Data +## Country and ASN 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). +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) and/or how many peers are in each ASN. To enable this functionality, you will need to download the appropriate MaxMind GeoLite2 database and provide the path to the exporter application. The paths can be provided with command line flags, an entry in the config yaml file , or an environment variable . To gain access to the MaxMind DBs, you can [register here](https://www.maxmind.com/en/geolite2/signup). + + +`--maxmind-country-db-path /path/to/GeoLite2-Country.mmdb` +`maxmind-country-db-path: /path/to/GeoLite2-Country.mmdb` +`CHIA_EXPORTER_MAXMIND_COUNTRY_DB_PATH=/path/to/GeoLite2-Country.mmdb`