From ca2ce3ffb619e32e815ea83f29e530bde4f74b32 Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 19 Dec 2016 12:09:59 -0800 Subject: [PATCH 1/2] Add server uptime reporting --- server/server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/server.go b/server/server.go index d4d6cf5f3c..25ea351b8b 100644 --- a/server/server.go +++ b/server/server.go @@ -19,6 +19,12 @@ import ( "github.com/tylerb/graceful" ) +var startTime time.Time + +func init() { + startTime = time.Now().UTC() +} + // Server for the chronograf API type Server struct { Host string `long:"host" description:"the IP to listen on" default:"0.0.0.0" env:"HOST"` @@ -162,6 +168,7 @@ func reportUsageStats(bi BuildInfo, logger chronograf.Logger) { "arch": runtime.GOARCH, "version": bi.Version, "cluster_id": serverID, + "uptime": time.Since(startTime).Seconds(), }, }, }, From 502887417f08d75cdf8ac99c2f573e439cccc64d Mon Sep 17 00:00:00 2001 From: Jack Zampolin Date: Mon, 19 Dec 2016 13:29:33 -0800 Subject: [PATCH 2/2] Address PR comments --- chronograf.go | 2 +- server/server.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chronograf.go b/chronograf.go index 1991f73875..a6c1912318 100644 --- a/chronograf.go +++ b/chronograf.go @@ -260,7 +260,7 @@ type Cell struct { I string `json:"i"` Name string `json:"name"` Queries []Query `json:"queries"` - Type string `json:"type"` + Type string `json:"type"` } // Layout is a collection of Cells for visualization diff --git a/server/server.go b/server/server.go index 25ea351b8b..a508ed7735 100644 --- a/server/server.go +++ b/server/server.go @@ -43,7 +43,7 @@ type Server struct { TokenSecret string `short:"t" long:"token-secret" description:"Secret to sign tokens" env:"TOKEN_SECRET"` GithubClientID string `short:"i" long:"github-client-id" description:"Github Client ID for OAuth 2 support" env:"GH_CLIENT_ID"` GithubClientSecret string `short:"s" long:"github-client-secret" description:"Github Client Secret for OAuth 2 support" env:"GH_CLIENT_SECRET"` - ReportingDisabled bool `short:"r" long:"reporting-disabled" description:"Disable reporting of usage stats (os,arch,version,cluster_id) once every 24hr" env:"REPORTING_DISABLED"` + ReportingDisabled bool `short:"r" long:"reporting-disabled" description:"Disable reporting of usage stats (os,arch,version,cluster_id,uptime) once every 24hr" env:"REPORTING_DISABLED"` LogLevel string `short:"l" long:"log-level" value-name:"choice" choice:"debug" choice:"info" choice:"warn" choice:"error" choice:"fatal" choice:"panic" default:"info" description:"Set the logging level" env:"LOG_LEVEL"` ShowVersion bool `short:"v" long:"version" description:"Show Chronograf version info"` @@ -168,7 +168,7 @@ func reportUsageStats(bi BuildInfo, logger chronograf.Logger) { "arch": runtime.GOARCH, "version": bi.Version, "cluster_id": serverID, - "uptime": time.Since(startTime).Seconds(), + "uptime": time.Since(startTime).Seconds(), }, }, }, @@ -176,7 +176,7 @@ func reportUsageStats(bi BuildInfo, logger chronograf.Logger) { l := logger.WithField("component", "usage"). WithField("reporting_addr", reporter.URL). WithField("freq", "24h"). - WithField("stats", "os,arch,version,cluster_id") + WithField("stats", "os,arch,version,cluster_id,uptime") l.Info("Reporting usage stats") reporter.Save(u)