<match **>
  @type secure_forward
  log_level "#{ENV['FORWARD_INPUT_LOG_LEVEL'] || ENV['LOG_LEVEL'] || 'warn'}"
  self_hostname ${hostname}
  shared_key "#{File.open('/etc/fluent/muxkeys/shared_key') do |f| f.readline end.rstrip}"
  secure yes
  ca_cert_path /etc/fluent/muxkeys/ca
  flush_interval "#{ENV['FORWARD_FLUSH_INTERVAL'] || '5s'}"
  buffer_queue_limit "#{ENV['BUFFER_QUEUE_LIMIT'] || '1024' }"
  buffer_chunk_limit "#{ENV['BUFFER_SIZE_LIMIT'] || '1m' }"
  max_retry_wait "#{ENV['FORWARD_RETRY_WAIT'] || '300'}"
  flush_at_shutdown "#{ENV['FLUSH_AT_SHUTDOWN'] || 'false'}"
  disable_retry_limit true
  buffer_type file
  buffer_path '/var/lib/fluentd/buffer-mux-client'
  # the systemd journald 0.0.8 input plugin will just throw away records if the buffer
  # queue limit is hit - 'block' will halt further reads and keep retrying to flush the
  # buffer to the remote - default is 'exception' because in_tail handles that case
  buffer_queue_full_action "#{ENV['BUFFER_QUEUE_FULL_ACTION'] || 'exception'}"
  <server>
    host logging-mux
    port "#{ENV['FORWARD_LISTEN_PORT'] || '24284'}"
  </server>
</match>
