From d46bf535b29488ecd7695eb1d53a6ebe5af527c9 Mon Sep 17 00:00:00 2001 From: Mark Bates Date: Fri, 6 Nov 2015 10:30:57 -0500 Subject: [PATCH] Report anonymous stats to Enterprise --- cmd/influxd/run/server.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/cmd/influxd/run/server.go b/cmd/influxd/run/server.go index 6ae658b71b..b7a81b0007 100644 --- a/cmd/influxd/run/server.go +++ b/cmd/influxd/run/server.go @@ -1,17 +1,16 @@ package run import ( - "bytes" "fmt" "log" "net" - "net/http" "os" "runtime" "runtime/pprof" "strings" "time" + "github.com/influxdb/enterprise-client/v1" "github.com/influxdb/influxdb/cluster" "github.com/influxdb/influxdb/meta" "github.com/influxdb/influxdb/monitor" @@ -512,18 +511,28 @@ func (s *Server) reportServer() { return } - json := fmt.Sprintf(`[{ - "name":"reports", - "columns":["os", "arch", "version", "server_id", "cluster_id", "num_series", "num_measurements", "num_databases"], - "points":[["%s", "%s", "%s", "%x", "%x", "%d", "%d", "%d"]] - }]`, runtime.GOOS, runtime.GOARCH, s.buildInfo.Version, s.MetaStore.NodeID(), clusterID, numSeries, numMeasurements, numDatabases) - - data := bytes.NewBufferString(json) + cl := client.New("") + usage := client.Usage{ + Product: "influxdb", + Data: []client.UsageData{ + { + Values: client.Values{ + "os": runtime.GOOS, + "arch": runtime.GOARCH, + "version": s.buildInfo.Version, + "server_id": s.MetaStore.NodeID(), + "cluster_id": clusterID, + "num_series": numSeries, + "num_measurements": numMeasurements, + "num_databases": numDatabases, + }, + }, + }, + } log.Printf("Sending anonymous usage statistics to m.influxdb.com") - client := http.Client{Timeout: time.Duration(5 * time.Second)} - go client.Post("http://m.influxdb.com:8086/db/reporting/series?u=reporter&p=influxdb", "application/json", data) + go cl.Save(usage) } // monitorErrorChan reads an error channel and resends it through the server.