From 82c27cb9024d9ec7721d9b265c4e7eb863552b2f Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 11 Jun 2014 10:18:19 -0700 Subject: [PATCH] agent: Adding SyslogFacility configuration --- command/agent/config.go | 8 ++++++++ command/agent/config_test.go | 5 ++++- website/source/docs/agent/options.html.markdown | 3 +++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/command/agent/config.go b/command/agent/config.go index f009e1e2da..dd98a05fb1 100644 --- a/command/agent/config.go +++ b/command/agent/config.go @@ -167,6 +167,10 @@ type Config struct { // on linux and OSX. Other platforms will generate an error. EnableSyslog bool `mapstructure:"enable_syslog"` + // SyslogFacility is used to control where the syslog messages go + // By default, goes to LOCAL0 + SyslogFacility string `mapstructure:"syslog_facility"` + // RejoinAfterLeave controls our interaction with the cluster after leave. // When set to false (default), a leave causes Consul to not rejoin // the cluster until an explicit join is received. If this is set to @@ -228,6 +232,7 @@ func DefaultConfig() *Config { DNSConfig: DNSConfig{ MaxStale: 5 * time.Second, }, + SyslogFacility: "LOCAL0", Protocol: consul.ProtocolVersionMax, CheckUpdateInterval: 5 * time.Minute, AEInterval: time.Minute, @@ -556,6 +561,9 @@ func MergeConfig(a, b *Config) *Config { if b.CheckUpdateIntervalRaw != "" || b.CheckUpdateInterval != 0 { result.CheckUpdateInterval = b.CheckUpdateInterval } + if b.SyslogFacility != "" { + result.SyslogFacility = b.SyslogFacility + } // Copy the start join addresses result.StartJoin = make([]string, 0, len(a.StartJoin)+len(b.StartJoin)) diff --git a/command/agent/config_test.go b/command/agent/config_test.go index 45da383547..2199b0823a 100644 --- a/command/agent/config_test.go +++ b/command/agent/config_test.go @@ -270,7 +270,7 @@ func TestDecodeConfig(t *testing.T) { } // Syslog - input = `{"enable_syslog": true}` + input = `{"enable_syslog": true, "syslog_facility": "LOCAL4"}` config, err = DecodeConfig(bytes.NewReader([]byte(input))) if err != nil { t.Fatalf("err: %s", err) @@ -279,6 +279,9 @@ func TestDecodeConfig(t *testing.T) { if !config.EnableSyslog { t.Fatalf("bad: %#v", config) } + if config.SyslogFacility != "LOCAL4" { + t.Fatalf("bad: %#v", config) + } // Rejoin input = `{"rejoin_after_leave": true}` diff --git a/website/source/docs/agent/options.html.markdown b/website/source/docs/agent/options.html.markdown index e108549a89..c9f1ae6f26 100644 --- a/website/source/docs/agent/options.html.markdown +++ b/website/source/docs/agent/options.html.markdown @@ -257,6 +257,9 @@ definitions support being updated during a reload. Consul will stream various telemetry information to that instance for aggregation. This can be used to capture various runtime information. +* `syslog_facility` - When `enable_syslog` is provided, this controls which + facility messages are sent to. By default, `LOCAL0` will be used. + * `verify_incoming` - If set to True, Consul requires that all incoming connections make use of TLS, and that the client provides a certificate signed by the Certificate Authority from the `ca_file`. By default, this is false, and