mirror of
https://github.com/status-im/consul.git
synced 2025-02-19 17:14:37 +00:00
agent: statsd support. Fixes #247
This commit is contained in:
parent
289cc265ee
commit
98acc0a908
@ -26,6 +26,7 @@ IMPROVEMENTS:
|
|||||||
* Support for HTTP `?pretty` parameter to pretty format JSON output.
|
* Support for HTTP `?pretty` parameter to pretty format JSON output.
|
||||||
* Use $SHELL when invoking handlers. [GH-237]
|
* Use $SHELL when invoking handlers. [GH-237]
|
||||||
* Agent takes the `-encrypt` CLI Flag [GH-245]
|
* Agent takes the `-encrypt` CLI Flag [GH-245]
|
||||||
|
* New `statsd_add` config for Statsd support. [GH-247]
|
||||||
|
|
||||||
BUG FIXES:
|
BUG FIXES:
|
||||||
|
|
||||||
|
@ -347,16 +347,31 @@ func (c *Command) Run(args []string) int {
|
|||||||
metrics.DefaultInmemSignal(inm)
|
metrics.DefaultInmemSignal(inm)
|
||||||
metricsConf := metrics.DefaultConfig("consul")
|
metricsConf := metrics.DefaultConfig("consul")
|
||||||
|
|
||||||
// Optionally configure a statsite sink if provided
|
// Configure the statsite sink
|
||||||
|
var fanout metrics.FanoutSink
|
||||||
if config.StatsiteAddr != "" {
|
if config.StatsiteAddr != "" {
|
||||||
sink, err := metrics.NewStatsiteSink(config.StatsiteAddr)
|
sink, err := metrics.NewStatsiteSink(config.StatsiteAddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Failed to start statsite sink. Got: %s", err))
|
c.Ui.Error(fmt.Sprintf("Failed to start statsite sink. Got: %s", err))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
fanout := metrics.FanoutSink{inm, sink}
|
fanout = append(fanout, sink)
|
||||||
metrics.NewGlobal(metricsConf, fanout)
|
}
|
||||||
|
|
||||||
|
// Configure the statsd sink
|
||||||
|
if config.StatsdAddr != "" {
|
||||||
|
sink, err := metrics.NewStatsdSink(config.StatsdAddr)
|
||||||
|
if err != nil {
|
||||||
|
c.Ui.Error(fmt.Sprintf("Failed to start statsd sink. Got: %s", err))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fanout = append(fanout, sink)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize the global sink
|
||||||
|
if len(fanout) > 0 {
|
||||||
|
fanout = append(fanout, inm)
|
||||||
|
metrics.NewGlobal(metricsConf, fanout)
|
||||||
} else {
|
} else {
|
||||||
metricsConf.EnableHostname = false
|
metricsConf.EnableHostname = false
|
||||||
metrics.NewGlobal(metricsConf, inm)
|
metrics.NewGlobal(metricsConf, inm)
|
||||||
|
@ -129,6 +129,10 @@ type Config struct {
|
|||||||
// metrics will be streamed to that instance.
|
// metrics will be streamed to that instance.
|
||||||
StatsiteAddr string `mapstructure:"statsite_addr"`
|
StatsiteAddr string `mapstructure:"statsite_addr"`
|
||||||
|
|
||||||
|
// StatsdAddr is the address of a statsd instance. If provided,
|
||||||
|
// metrics will be sent to that instance.
|
||||||
|
StatsdAddr string `mapstructure:"statsd_addr"`
|
||||||
|
|
||||||
// Protocol is the Consul protocol version to use.
|
// Protocol is the Consul protocol version to use.
|
||||||
Protocol int `mapstructure:"protocol"`
|
Protocol int `mapstructure:"protocol"`
|
||||||
|
|
||||||
@ -575,6 +579,9 @@ func MergeConfig(a, b *Config) *Config {
|
|||||||
if b.StatsiteAddr != "" {
|
if b.StatsiteAddr != "" {
|
||||||
result.StatsiteAddr = b.StatsiteAddr
|
result.StatsiteAddr = b.StatsiteAddr
|
||||||
}
|
}
|
||||||
|
if b.StatsdAddr != "" {
|
||||||
|
result.StatsdAddr = b.StatsdAddr
|
||||||
|
}
|
||||||
if b.EnableDebug {
|
if b.EnableDebug {
|
||||||
result.EnableDebug = true
|
result.EnableDebug = true
|
||||||
}
|
}
|
||||||
|
@ -416,6 +416,20 @@ func TestDecodeConfig(t *testing.T) {
|
|||||||
if !config.DisableRemoteExec {
|
if !config.DisableRemoteExec {
|
||||||
t.Fatalf("bad: %#v", config)
|
t.Fatalf("bad: %#v", config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// stats(d|ite) exec
|
||||||
|
input = `{"statsite_addr": "127.0.0.1:7250", "statsd_addr": "127.0.0.1:7251"}`
|
||||||
|
config, err = DecodeConfig(bytes.NewReader([]byte(input)))
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.StatsiteAddr != "127.0.0.1:7250" {
|
||||||
|
t.Fatalf("bad: %#v", config)
|
||||||
|
}
|
||||||
|
if config.StatsdAddr != "127.0.0.1:7251" {
|
||||||
|
t.Fatalf("bad: %#v", config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDecodeConfig_Service(t *testing.T) {
|
func TestDecodeConfig_Service(t *testing.T) {
|
||||||
@ -578,6 +592,8 @@ func TestMergeConfig(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
DisableRemoteExec: true,
|
DisableRemoteExec: true,
|
||||||
|
StatsiteAddr: "127.0.0.1:7250",
|
||||||
|
StatsdAddr: "127.0.0.1:7251",
|
||||||
}
|
}
|
||||||
|
|
||||||
c := MergeConfig(a, b)
|
c := MergeConfig(a, b)
|
||||||
|
@ -309,9 +309,15 @@ definitions support being updated during a reload.
|
|||||||
* `start_join` - An array of strings specifying addresses of nodes to
|
* `start_join` - An array of strings specifying addresses of nodes to
|
||||||
join upon startup.
|
join upon startup.
|
||||||
|
|
||||||
|
* `statsd_addr` - This provides the address of a statsd instance. If provided
|
||||||
|
Consul will send various telemetry information to that instance for aggregation.
|
||||||
|
This can be used to capture various runtime information. This sends UDP packets
|
||||||
|
only, and can be used with statsd or statsite.
|
||||||
|
|
||||||
* `statsite_addr` - This provides the address of a statsite instance. If provided
|
* `statsite_addr` - This provides the address of a statsite instance. If provided
|
||||||
Consul will stream various telemetry information to that instance for aggregation.
|
Consul will stream various telemetry information to that instance for aggregation.
|
||||||
This can be used to capture various runtime information.
|
This can be used to capture various runtime information. This streams via
|
||||||
|
TCP and can only be used with statsite.
|
||||||
|
|
||||||
* `syslog_facility` - When `enable_syslog` is provided, this controls which
|
* `syslog_facility` - When `enable_syslog` is provided, this controls which
|
||||||
facility messages are sent to. By default, `LOCAL0` will be used.
|
facility messages are sent to. By default, `LOCAL0` will be used.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user