Config option for diagnostics interval. Default to 1 hour

This commit is contained in:
Michael Baird 2017-10-17 13:50:28 -05:00
parent e48ade4a9e
commit 722e73d305
4 changed files with 14 additions and 4 deletions

View file

@ -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
}

View file

@ -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)
}

View file

@ -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))

View file

@ -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
}