github.com/grafana/pyroscope@v1.18.0/pkg/metrics/config.go (about) 1 package metrics 2 3 import ( 4 "errors" 5 "flag" 6 ) 7 8 type Config struct { 9 Enabled bool `yaml:"enabled"` 10 RulesSource struct { 11 ClientAddress string `yaml:"client_address"` 12 } `yaml:"rules_source"` 13 RemoteWriteAddress string `yaml:"remote_write_address"` 14 } 15 16 func (c *Config) Validate() error { 17 if !c.Enabled { 18 return nil 19 } 20 if c.RemoteWriteAddress == "" { 21 return errors.New("remote write address is required") 22 } 23 return nil 24 } 25 26 func (c *Config) RegisterFlags(f *flag.FlagSet) { 27 const prefix = "compaction-worker.metrics-exporter." 28 29 f.BoolVar(&c.Enabled, prefix+"enabled", false, "This parameter specifies whether the metrics exporter is enabled.") 30 f.StringVar(&c.RulesSource.ClientAddress, prefix+"rules-source.client-address", "", "The address to use for the recording rules client connection.") 31 f.StringVar(&c.RemoteWriteAddress, prefix+"remote-write-address", "", "The address to use for metrics tenant.") 32 }