agent: Adding support for statsite telemetry
This commit is contained in:
parent
46830a3c8f
commit
981e58e8e9
|
@ -59,6 +59,7 @@ func (c *Command) readConfig() *Config {
|
|||
cmdFlags.StringVar(&cmdConfig.DNSAddr, "dns-addr", "", "address to bind dns server to")
|
||||
cmdFlags.BoolVar(&cmdConfig.Server, "server", false, "run agent as server")
|
||||
cmdFlags.BoolVar(&cmdConfig.Bootstrap, "bootstrap", false, "enable server bootstrap mode")
|
||||
cmdFlags.StringVar(&cmdConfig.StatsiteAddr, "statsite", "", "address of statsite instance")
|
||||
if err := cmdFlags.Parse(c.args); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
@ -195,8 +196,21 @@ func (c *Command) Run(args []string) int {
|
|||
inm := metrics.NewInmemSink(10*time.Second, time.Minute)
|
||||
metrics.DefaultInmemSignal(inm)
|
||||
metricsConf := metrics.DefaultConfig("consul")
|
||||
metricsConf.EnableHostname = false
|
||||
metrics.NewGlobal(metricsConf, inm)
|
||||
|
||||
// Optionally configure a statsite sink if provided
|
||||
if config.StatsiteAddr != "" {
|
||||
sink, err := metrics.NewStatsiteSink(config.StatsiteAddr)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Failed to start statsite sink. Got: %s", err))
|
||||
return 1
|
||||
}
|
||||
fanout := metrics.FanoutSink{inm, sink}
|
||||
metrics.NewGlobal(metricsConf, fanout)
|
||||
|
||||
} else {
|
||||
metricsConf.EnableHostname = false
|
||||
metrics.NewGlobal(metricsConf, inm)
|
||||
}
|
||||
|
||||
// Create the agent
|
||||
if err := c.setupAgent(config, logOutput, logWriter); err != nil {
|
||||
|
|
|
@ -93,6 +93,10 @@ type Config struct {
|
|||
// the INT signal. Defaults false. This can be changed on reload.
|
||||
SkipLeaveOnInt bool `mapstructure:"skip_leave_on_interrupt"`
|
||||
|
||||
// StatsiteAddr is the address of a statsite instance. If provided,
|
||||
// metrics will be streamed to that instance.
|
||||
StatsiteAddr string `mapstructure:"statsite_addr"`
|
||||
|
||||
// Checks holds the provided check definitions
|
||||
Checks []*CheckDefinition `mapstructure:"-"`
|
||||
|
||||
|
|
|
@ -114,6 +114,10 @@ The options below are all specified on the command-line.
|
|||
nodes are able to self-elect. Once there are multiple servers in a datacenter, it is generally a good idea
|
||||
to disable bootstrap mode on all of them.
|
||||
|
||||
* `-statsite` - This flag provides the address of a statsite instance. If provided Consul will stream
|
||||
various telemetry information to that instance for aggregation. This can be used to capture various
|
||||
runtime information.
|
||||
|
||||
## Configuration Files
|
||||
|
||||
In addition to the command-line options, configuration can be put into
|
||||
|
@ -194,3 +198,5 @@ They are documented seperately under [check configuration](/docs/agent/checks.ht
|
|||
gracefully leave, but setting this to true disables that. Defaults to false.
|
||||
Interrupts are usually from a Control-C from a shell.
|
||||
|
||||
* `statsite_addr` - Equivalent to the `-statsite` command-line flag.
|
||||
|
||||
|
|
Loading…
Reference in New Issue