mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 02:15:43 +03:00
agent: allow configuration of in-memory telemetry sink. (#20166)
This change adds configuration options for setting the in-memory telemetry sink collection and retention durations. This sink backs the metrics JSON API and previously had hard-coded default values. The new options are particularly useful when running development or debug environments, where metrics collection is desired at a fast and granular rate.
This commit is contained in:
@@ -352,6 +352,11 @@ func (c *Command) IsValidConfig(config, cmdConfig *Config) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
if err := config.Telemetry.Validate(); err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("telemetry block invalid: %v", err))
|
||||
return false
|
||||
}
|
||||
|
||||
// Set up the TLS configuration properly if we have one.
|
||||
// XXX chelseakomlo: set up a TLSConfig New method which would wrap
|
||||
// constructor-type actions like this.
|
||||
@@ -1155,14 +1160,8 @@ func (c *Command) handleReload() {
|
||||
}
|
||||
}
|
||||
|
||||
// setupTelemetry is used ot setup the telemetry sub-systems
|
||||
// setupTelemetry is used to set up the telemetry sub-systems.
|
||||
func (c *Command) setupTelemetry(config *Config) (*metrics.InmemSink, error) {
|
||||
/* Setup telemetry
|
||||
Aggregate on 10 second intervals for 1 minute. Expose the
|
||||
metrics over stderr when there is a SIGUSR1 received.
|
||||
*/
|
||||
inm := metrics.NewInmemSink(10*time.Second, time.Minute)
|
||||
metrics.DefaultInmemSignal(inm)
|
||||
|
||||
var telConfig *Telemetry
|
||||
if config.Telemetry == nil {
|
||||
@@ -1171,6 +1170,9 @@ func (c *Command) setupTelemetry(config *Config) (*metrics.InmemSink, error) {
|
||||
telConfig = config.Telemetry
|
||||
}
|
||||
|
||||
inm := metrics.NewInmemSink(telConfig.inMemoryCollectionInterval, telConfig.inMemoryRetentionPeriod)
|
||||
metrics.DefaultInmemSignal(inm)
|
||||
|
||||
metricsConf := metrics.DefaultConfig("nomad")
|
||||
metricsConf.EnableHostname = !telConfig.DisableHostname
|
||||
|
||||
|
||||
Reference in New Issue
Block a user