diff --git a/jobs/gorouter/spec b/jobs/gorouter/spec index 8247cbe7b..66e526667 100644 --- a/jobs/gorouter/spec +++ b/jobs/gorouter/spec @@ -278,6 +278,15 @@ properties: router.enable_log_attempts_details: description: "Log additional fields in the access log that provide more details on the specific timings and attempts performed towards endpoints." default: false + router.logging.syslog_tag: + description: "Tag to use when writing syslog messages" + default: "vcap.gorouter" + router.logging.syslog_addr: + description: "Address of a syslog server to send access logs" + default: "localhost:514" + router.logging.syslog_network: + description: "Network protocol to use when connecting to the syslog server. Valid values are 'tcp', 'udp', . When choosing an empty string value, the local syslog daemon is used." + default: "udp" router.logging.format.timestamp: description: | Format for timestamp in component logs. Valid values are 'rfc3339', 'deprecated', and 'unix-epoch'." @@ -496,6 +505,9 @@ properties: router.write_access_logs_locally: description: "Enables writing access log to local disk." default: true + router.enable_access_log_streaming: + description: "Enables streaming access log to syslog server." + default: false router.suspend_pruning_if_nats_unavailable: description: | Suspend pruning of routes when NATs is unavailable and maintain the diff --git a/jobs/gorouter/templates/gorouter.yml.erb b/jobs/gorouter/templates/gorouter.yml.erb index 508050fce..f3a7e4a7f 100644 --- a/jobs/gorouter/templates/gorouter.yml.erb +++ b/jobs/gorouter/templates/gorouter.yml.erb @@ -110,6 +110,7 @@ params = { 'sticky_sessions_for_auth_negotiate' => p('router.sticky_sessions_for_auth_negotiate'), 'access_log' => { 'file' => access_log_file, + 'enable_streaming' => p('router.enable_access_log_streaming') }, 'publish_start_message_interval' => '30s', 'prune_stale_droplets_interval' => '30s', @@ -374,7 +375,9 @@ if timestamp_format == 'deprecated' end params['logging'] = { - 'syslog' => 'vcap.gorouter', + 'syslog' => p('router.logging.syslog_tag'), + 'syslog_addr' => p('router.logging.syslog_addr'), + 'syslog_network' => p('router.logging.syslog_network'), 'level' => p('router.logging_level'), 'loggregator_enabled' => true, 'metron_address' => "localhost:#{p('metron.port')}", diff --git a/spec/gorouter_templates_spec.rb b/spec/gorouter_templates_spec.rb index c38de84bf..123371307 100644 --- a/spec/gorouter_templates_spec.rb +++ b/spec/gorouter_templates_spec.rb @@ -1214,7 +1214,7 @@ end end - fcontext 'when the timestamp format is set to deprecated' do + context 'when the timestamp format is set to deprecated' do before do deployment_manifest_fragment['router']['logging'] = { 'format' => { 'timestamp' => 'deprecated' } } end @@ -1248,6 +1248,46 @@ expect(parsed_yaml['logging']['enable_attempts_details']).to eq(true) end end + + context 'when access log streaming via syslog is enabled' do + before do + deployment_manifest_fragment['router']['write_access_logs_locally'] = false + deployment_manifest_fragment['router']['enable_access_log_streaming'] = true + end + it 'it properly sets the value' do + expect(parsed_yaml['access_log']['file']).to eq('') + expect(parsed_yaml['access_log']['enable_streaming']).to eq(true) + end + it 'it properly sets default values' do + expect(parsed_yaml['logging']['syslog']).to eq('vcap.gorouter') + expect(parsed_yaml['logging']['syslog_addr']).to eq('localhost:514') + expect(parsed_yaml['logging']['syslog_network']).to eq('udp') + end + context 'when syslog tag is set' do + before do + deployment_manifest_fragment['router']['logging'] = { 'syslog_tag' => 'funny.cat' } + end + it 'it properly sets the value' do + expect(parsed_yaml['logging']['syslog']).to eq('funny.cat') + end + end + context 'when syslog address is set' do + before do + deployment_manifest_fragment['router']['logging'] = { 'syslog_addr' => '10.0.1.2:1234' } + end + it 'it properly sets the value' do + expect(parsed_yaml['logging']['syslog_addr']).to eq('10.0.1.2:1234') + end + end + context 'when syslog network protocol is set' do + before do + deployment_manifest_fragment['router']['logging'] = { 'syslog_network' => 'tcp' } + end + it 'it properly sets default values' do + expect(parsed_yaml['logging']['syslog_network']).to eq('tcp') + end + end + end end context 'tracing' do