diff --git a/cmd/kapacitord/run/config.go b/cmd/kapacitord/run/config.go index b7d14ebc5..790ece472 100644 --- a/cmd/kapacitord/run/config.go +++ b/cmd/kapacitord/run/config.go @@ -49,7 +49,6 @@ type Config struct { Hostname string `toml:"hostname"` DataDir string `toml:"data_dir"` - Token string `toml:"token"` } // NewConfig returns an instance of Config with reasonable defaults. diff --git a/cmd/kapacitord/run/server.go b/cmd/kapacitord/run/server.go index b84f9d3a0..d71d6db7d 100644 --- a/cmd/kapacitord/run/server.go +++ b/cmd/kapacitord/run/server.go @@ -147,7 +147,7 @@ func NewServer(c *Config, buildInfo *BuildInfo, logService logging.Interface) (* // append StatsService and ReportingService last so all stats are ready // to be reported s.appendStatsService(c.Stats) - s.appendReportingService(c.Reporting, c.Token) + s.appendReportingService(c.Reporting) return s, nil } @@ -306,10 +306,10 @@ func (s *Server) appendStatsService(c stats.Config) { } } -func (s *Server) appendReportingService(c reporting.Config, token string) { +func (s *Server) appendReportingService(c reporting.Config) { if c.Enabled { l := s.LogService.NewLogger("[reporting] ", log.LstdFlags) - srv := reporting.NewService(c, token, l) + srv := reporting.NewService(c, l) s.Services = append(s.Services, srv) } diff --git a/etc/kapacitor/kapacitor.conf b/etc/kapacitor/kapacitor.conf index e85db6b51..7269a7336 100644 --- a/etc/kapacitor/kapacitor.conf +++ b/etc/kapacitor/kapacitor.conf @@ -3,11 +3,6 @@ hostname = "localhost" # Directory for storing a small amount of metadata about the server. data_dir = "/var/lib/kapacitor" -# Your Enterprise token. By using Enterprise you can -# send all internal statistics to the Enterprise -# endpoints which will store and report on the -# activity of your instances. -token = "" [http] # HTTP API Server for Kapacitor @@ -140,12 +135,7 @@ token = "" # Send anonymous usage statistics # every 12 hours to Enterprise. enabled = true - enterprise-url = "https://enterprise.influxdata.com" - # The interval at which to send all - # internal statistics to Enterprise. - # If no token is specified this - # setting has no effect. - stats-interval = "1m0s" + url = "https://usage.influxdata.com" ################################## # Input Methods, same as InfluxDB diff --git a/services/reporting/config.go b/services/reporting/config.go index 46739dce7..e4d9eca96 100644 --- a/services/reporting/config.go +++ b/services/reporting/config.go @@ -1,22 +1,17 @@ package reporting import ( - "time" - - "github.com/influxdb/enterprise-client/v1" - "github.com/influxdb/influxdb/toml" + "github.com/influxdb/usage-client/v1" ) type Config struct { - Enabled bool `toml:"enabled"` - EnterpriseURL string `toml:"enterprise-url"` - StatsInterval toml.Duration `toml:"stats-interval"` + Enabled bool `toml:"enabled"` + URL string `toml:"url"` } func NewConfig() Config { return Config{ - Enabled: true, - EnterpriseURL: client.URL, - StatsInterval: toml.Duration(time.Minute), + Enabled: true, + URL: client.URL, } } diff --git a/services/reporting/service.go b/services/reporting/service.go index b7131e2fd..867f50654 100644 --- a/services/reporting/service.go +++ b/services/reporting/service.go @@ -7,19 +7,13 @@ import ( "sync" "time" - "github.com/influxdb/enterprise-client/v1" "github.com/influxdb/kapacitor" + "github.com/influxdb/usage-client/v1" ) const reportingInterval = time.Hour * 12 -// Sends periodic information to Enterprise. -// If not registered with Enterprise just -// registers the server on startup and sends anonymous -// stats every 12 hours. -// -// If registered with Enterprise also sends -// all expvar statistics at the Config.StatsInterval. +// Sends anonymous usage information every 12 hours. type Service struct { tags client.Tags @@ -31,21 +25,19 @@ type Service struct { version string product string - statsInterval time.Duration - statsTicker *time.Ticker - usageTicker *time.Ticker - closing chan struct{} - logger *log.Logger - wg sync.WaitGroup + statsTicker *time.Ticker + usageTicker *time.Ticker + closing chan struct{} + logger *log.Logger + wg sync.WaitGroup } -func NewService(c Config, token string, l *log.Logger) *Service { - client := client.New(token) - client.URL = c.EnterpriseURL +func NewService(c Config, l *log.Logger) *Service { + client := client.New("") + client.URL = c.URL return &Service{ - client: client, - logger: l, - statsInterval: time.Duration(c.StatsInterval), + client: client, + logger: l, } } @@ -67,30 +59,9 @@ func (s *Service) Open() error { s.tags["arch"] = runtime.GOARCH s.tags["os"] = runtime.GOOS - // Check for enterprise token - if s.client.Token == "" { - r := client.Registration{ - ClusterID: s.clusterID, - Product: s.product, - } - u, _ := s.client.RegistrationURL(r) - s.logger.Println("E! No Enterprise token configured, please register at", u) - } else { - // Send periodic stats - s.statsTicker = time.NewTicker(s.statsInterval) - s.wg.Add(1) - go s.stats() - } - - // Register server on startup - err := s.registerServer() - if err != nil { - s.logger.Println("E! error registering server:", err) - } - // Send anonymous usage stats on startup s.usageTicker = time.NewTicker(reportingInterval) - err = s.sendUsageReport() + err := s.sendUsageReport() if err != nil { s.logger.Println("E! error sending usage stats:", err) } @@ -130,37 +101,6 @@ func (s *Service) usage() { } } -func (s *Service) stats() { - defer s.wg.Done() - for { - select { - case <-s.closing: - return - case <-s.statsTicker.C: - err := s.sendStatsReport() - if err != nil { - s.logger.Println("E! error while sending stats report:", err) - } - } - } -} - -// Register this server with Enterprise. -func (s *Service) registerServer() error { - server := client.Server{ - ClusterID: s.clusterID, - ServerID: s.serverID, - Host: s.hostname, - Version: s.version, - Product: s.product, - } - resp, err := s.client.Save(server) - if resp != nil { - resp.Body.Close() - } - return err -} - // Send anonymous usage report. func (s *Service) sendUsageReport() error { data := client.UsageData{ @@ -186,23 +126,3 @@ func (s *Service) sendUsageReport() error { } return err } - -// Send all internal stats. -func (s *Service) sendStatsReport() error { - data, err := kapacitor.GetStatsData() - if err != nil { - return err - } - stats := client.Stats{ - ClusterID: s.clusterID, - ServerID: s.serverID, - Product: s.product, - Data: data, - } - - resp, err := s.client.Save(stats) - if resp != nil { - resp.Body.Close() - } - return err -} diff --git a/stats.go b/stats.go index 95f658f74..3927843e1 100644 --- a/stats.go +++ b/stats.go @@ -7,7 +7,6 @@ import ( "sync" "time" - "github.com/influxdb/enterprise-client/v1" "github.com/twinj/uuid" ) @@ -116,13 +115,19 @@ func NewStatistics(name string, tags map[string]string) *expvar.Map { return statMap } +type StatsData struct { + Name string `json:"name"` + Tags map[string]string `json:"tags"` + Values map[string]interface{} `json:"values"` +} + // Return all stats data from the expvars. -func GetStatsData() ([]client.StatsData, error) { - allData := make([]client.StatsData, 0) +func GetStatsData() ([]StatsData, error) { + allData := make([]StatsData, 0) // Add Global expvars - globalData := client.StatsData{ + globalData := StatsData{ Name: "kapacitor", - Values: make(client.Values), + Values: make(map[string]interface{}), } allData = append(allData, globalData) @@ -142,9 +147,9 @@ func GetStatsData() ([]client.StatsData, error) { globalData.Values[kv.Key] = f } case *expvar.Map: - data := client.StatsData{ - Tags: make(client.Tags), - Values: make(client.Values), + data := StatsData{ + Tags: make(map[string]string), + Values: make(map[string]interface{}), } v.Do(func(subKV expvar.KeyValue) { @@ -191,7 +196,7 @@ func GetStatsData() ([]client.StatsData, error) { } }) - // If a registered client has no field data, don't include it in the results + // If no field data, don't include it in the results if len(data.Values) == 0 { return } @@ -204,13 +209,13 @@ func GetStatsData() ([]client.StatsData, error) { globalData.Values[UptimeVarName] = Uptime().Seconds() // Add Go memstats. - data := client.StatsData{ + data := StatsData{ Name: "runtime", } var rt runtime.MemStats runtime.ReadMemStats(&rt) - data.Values = client.Values{ + data.Values = map[string]interface{}{ "Alloc": int64(rt.Alloc), "TotalAlloc": int64(rt.TotalAlloc), "Sys": int64(rt.Sys),