Skip to content

Commit 4035c8a

Browse files
committed
add TLS support
1 parent 5fb6655 commit 4035c8a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/fluent/plugin/out_otlp.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module Fluent::Plugin
1313
class OtlpOutput < Output
1414
Fluent::Plugin.register_output("otlp", self)
1515

16+
helpers :server
17+
1618
config_section :buffer do
1719
config_set_default :chunk_keys, ["tag"]
1820
config_set_default :flush_at_shutdown, true
@@ -26,6 +28,10 @@ class OtlpOutput < Output
2628
config_param :proxy, :string, default: ENV["HTTP_PROXY"] || ENV["http_proxy"]
2729
end
2830

31+
config_section :transport, required: false, multi: false, init: true, param_name: :transport_config do
32+
config_argument :protocol, :enum, list: [:tls], default: nil
33+
end
34+
2935
desc "Compress request body"
3036
config_param :compress, :enum, list: %i[text gzip], default: :text
3137

@@ -41,6 +47,15 @@ def configure(conf)
4147
OtlpOutput.const_set(:HTTP_LOGS_ENDPOINT, "#{@http_config.endpoint}/v1/logs".freeze)
4248
OtlpOutput.const_set(:HTTP_METRICS_ENDPOINT, "#{@http_config.endpoint}/v1/metrics".freeze)
4349
OtlpOutput.const_set(:HTTP_TRACES_ENDPOINT, "#{@http_config.endpoint}/v1/traces".freeze)
50+
51+
@certs = {}
52+
if @transport_config.protocol == :tls
53+
@certs[:client_cert] = @transport_config.cert_path
54+
@certs[:client_key] = @transport_config.private_key_path
55+
@certs[:client_key_pass] = @transport_config.private_key_passphrase
56+
@certs[:ssl_verify_peer] = false if @transport_config.insecure
57+
@certs[:ssl_version] = @transport_config.version
58+
end
4459
end
4560

4661
def multi_workers_ready?
@@ -87,7 +102,7 @@ def create_connection(chunk)
87102
body = gz.close.string
88103
end
89104

90-
connection = Excon.new(uri, body: body, headers: headers, proxy: @http_config.proxy, persistent: true)
105+
connection = Excon.new(uri, body: body, headers: headers, proxy: @http_config.proxy, persistent: true, **@certs)
91106
[uri, connection]
92107
end
93108
end

0 commit comments

Comments
 (0)