Skip to content

Commit

Permalink
Update readme for country + ASN db support. Change flag to include co…
Browse files Browse the repository at this point in the history
…untry in the name
  • Loading branch information
cmmarslender committed Mar 6, 2024
1 parent 72ca948 commit 0650f45
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ 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")
rootCmd.PersistentFlags().BoolVar(&logBlockTimes, "log-block-times", false, "Enables logging of block (pre)validation times to log files.")

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")))
Expand Down
2 changes: 1 addition & 1 deletion internal/metrics/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 7 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

0 comments on commit 0650f45

Please sign in to comment.