From 722e73d30534999fd4950dae0b963acc9e96e121 Mon Sep 17 00:00:00 2001 From: Michael Baird Date: Tue, 17 Oct 2017 13:50:28 -0500 Subject: [PATCH] Config option for diagnostics interval. Default to 1 hour --- config.go | 11 ++++++++--- ctl/server.go | 1 + server.go | 4 +++- server/server.go | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/config.go b/config.go index fe93be19e..68a351523 100644 --- a/config.go +++ b/config.go @@ -43,6 +43,9 @@ const ( // DefaultMaxWritesPerRequest is the default number of writes per request. DefaultMaxWritesPerRequest = 5000 + + // DefaultDiagnosticsInterval is the default sync frequency diagnostic metrics. + DefaultDiagnosticsInterval = 1 * time.Hour ) // ClusterTypes set of cluster types. @@ -88,9 +91,10 @@ type Config struct { LogPath string `toml:"log-path"` Metric struct { - Service string `toml:"service"` - Host string `toml:"host"` - PollInterval Duration `toml:"poll-interval"` + Service string `toml:"service"` + Host string `toml:"host"` + PollInterval Duration `toml:"poll-interval"` + DiagnosticInterval Duration `toml:"diagnostics"` } `toml:"metric"` TLS TLSConfig @@ -108,6 +112,7 @@ func NewConfig() *Config { c.Cluster.Hosts = []string{} c.AntiEntropy.Interval = Duration(DefaultAntiEntropyInterval) c.Metric.Service = DefaultMetrics + c.Metric.DiagnosticInterval = Duration(DefaultDiagnosticsInterval) c.TLS = TLSConfig{} return c } diff --git a/ctl/server.go b/ctl/server.go index a0c080729..a39c86e3e 100644 --- a/ctl/server.go +++ b/ctl/server.go @@ -41,6 +41,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) { flags.StringVarP(&srv.Config.Cluster.Type, "cluster.type", "", "gossip", "Determine how the cluster handles membership and state sharing. Choose from [static, gossip]") flags.StringVarP(&srv.Config.Metric.Service, "metric.service", "", "nop", "Default URI on which pilosa should listen.") flags.StringVarP(&srv.Config.Metric.Host, "metric.host", "", "", "Default URI to send metrics.") + flags.DurationVarP((*time.Duration)(&srv.Config.Metric.DiagnosticInterval), "metric.diagnostics", "", time.Hour*1, "Diagnostic reporting interval back to Pilosa.") flags.DurationVarP((*time.Duration)(&srv.Config.Metric.PollInterval), "metric.poll-interval", "", time.Minute*0, "Polling interval metrics.") SetTLSConfig(flags, &srv.Config.TLS.CertificatePath, &srv.Config.TLS.CertificateKeyPath, &srv.Config.TLS.SkipVerify) } diff --git a/server.go b/server.go index 430bce7dc..d9b4209fc 100644 --- a/server.go +++ b/server.go @@ -99,7 +99,7 @@ func NewServer() *Server { AntiEntropyInterval: DefaultAntiEntropyInterval, PollingInterval: DefaultPollingInterval, MetricInterval: 0, - DiagnosticInterval: diagnostics.DefaultDiagnosticsInterval, + DiagnosticInterval: 0, LogOutput: os.Stderr, } @@ -522,6 +522,8 @@ func (s *Server) monitorDiagnostics() { s.diagnostics.SetLogger(s.LogOutput) s.diagnostics.SetVersion(Version) + s.diagnostics.SetInterval(s.DiagnosticInterval) + s.diagnostics.Open() s.diagnostics.Set("Host", s.URI.host) s.diagnostics.Set("Cluster", strings.Join(s.Cluster.NodeSetHosts(), ",")) s.diagnostics.Set("NumNodes", len(s.Cluster.Nodes)) diff --git a/server/server.go b/server/server.go index d1063f306..fb18137ad 100644 --- a/server/server.go +++ b/server/server.go @@ -30,6 +30,7 @@ import ( "time" "crypto/tls" + "github.com/pilosa/pilosa" "github.com/pilosa/pilosa/gossip" "github.com/pilosa/pilosa/statsd" @@ -143,6 +144,7 @@ func (m *Command) SetupServer() error { m.Server.Holder.Path = m.Config.DataDir m.Server.MetricInterval = time.Duration(m.Config.Metric.PollInterval) m.Server.Holder.Stats, err = NewStatsClient(m.Config.Metric.Service, m.Config.Metric.Host) + m.Server.DiagnosticInterval = time.Duration(m.Config.Metric.DiagnosticInterval) if err != nil { return err }