Skip to content

Commit

Permalink
fix: Enable syslog forwarding for gorouter
Browse files Browse the repository at this point in the history
  • Loading branch information
domdom82 authored and geofffranks committed Mar 3, 2024
1 parent 8465c0e commit 550c9b2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
12 changes: 12 additions & 0 deletions jobs/gorouter/spec
Original file line number Diff line number Diff line change
Expand Up @@ -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', <empty>. 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'."
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion jobs/gorouter/templates/gorouter.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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')}",
Expand Down
42 changes: 41 additions & 1 deletion spec/gorouter_templates_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 550c9b2

Please sign in to comment.