Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics: Add support for InfluxDB Database / RetentionPolicy and HTTP client #3391

Merged
merged 8 commits into from
May 29, 2018
23 changes: 16 additions & 7 deletions metrics/influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,31 @@ func RegisterInfluxDB(config *types.InfluxDB) Registry {

// initInfluxDBTicker creates a influxDBClient
func initInfluxDBClient(config *types.InfluxDB) *influx.Influx {
if config.Protocol == "udp" {
// TODO deprecated: move this switch into configuration.SetEffectiveConfiguration when web provider will be removed.
switch config.Protocol {
case "udp":
if len(config.Database) > 0 || len(config.RetentionPolicy) > 0 {
log.Warn("Database and RetentionPolicy are only used when protocol is http")
log.Warn("Database and RetentionPolicy are only used when protocol is http.")
config.Database = ""
config.RetentionPolicy = ""
}
} else if config.Protocol == "http" {
case "http":
if u, err := url.Parse(config.Address); err == nil {
if u.Scheme != "http" && u.Scheme != "https" {
log.Warnf("InfluxDB address %s should specify a scheme of http or https, defaulting to http", config.Address)
log.Warnf("InfluxDB address %s should specify a scheme of http or https, defaulting to http.", config.Address)
config.Address = "http://" + config.Address
}
} else {
log.Errorf("Unable to parse influxdb address: %s", err)
log.Errorf("Unable to parse influxdb address: %v, defaulting to udp.", err)
config.Protocol = "udp"
config.Database = ""
config.RetentionPolicy = ""
}
} else {
log.Warnf("Unsupported protocol: %s, defaulting to udp")
default:
log.Warnf("Unsupported protocol: %s, defaulting to udp.", config.Address)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be

log.Warnf("Unsupported protocol: %s, defaulting to udp.", config.Protocol)

config.Protocol = "udp"
config.Database = ""
config.RetentionPolicy = ""
}

return influx.New(
Expand Down