Skip to content

Commit

Permalink
Merge pull request emsearcy#1 from durchblicker/master
Browse files Browse the repository at this point in the history
add tcp tls support
  • Loading branch information
aayamauchi authored Jun 13, 2017
2 parents 1812a75 + 4ac3465 commit fb6fe3b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ gem install fluent-plugin-gelf
host <remote GELF host>
port <remote GELF port>
protocol <tcp or udp (default)>
tls <true or false (default)>
tls_options <{} (default)> for options see https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/transport/tcp_tls.rb#L7-L12
[ fluent buffered output plugin configuration ]
</match>
```
Expand Down
12 changes: 11 additions & 1 deletion lib/fluent/plugin/out_gelf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class GELFOutput < BufferedOutput
config_param :host, :string, :default => nil
config_param :port, :integer, :default => 12201
config_param :protocol, :string, :default => 'udp'
config_param :tls, :bool, :default => false
config_param :tls_options, :hash, :default => {}

def initialize
super
Expand All @@ -35,7 +37,15 @@ def configure(conf)
def start
super

@conn = GELF::Notifier.new(@host, @port, 'WAN', {:facility => 'fluentd', :protocol => @proto})
options = {:facility => 'fluentd', :protocol => @proto}

# add tls key (tls_options) only when tls = True
# see https://github.com/graylog-labs/gelf-rb/blob/72916932b789f7a6768c3cdd6ab69a3c942dbcef/lib/gelf/notifier.rb#L133-L140
if @tls then
options[:tls] = @tls_options
end

@conn = GELF::Notifier.new(@host, @port, 'WAN', options)

# Errors are not coming from Ruby so we use direct mapping
@conn.level_mapping = 'direct'
Expand Down

0 comments on commit fb6fe3b

Please sign in to comment.