Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LOG-4811: Fluentd is unable to forward logs to external ipv6 elastics…
…earch instance
- Loading branch information
Showing
2 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
diff --git a/lib/fluent/plugin/out_elasticsearch.rb b/lib/fluent/plugin/out_elasticsearch.rb | ||
index 8780f0aef..e881a3f03 100644 | ||
--- a/lib/fluent/plugin/out_elasticsearch.rb | ||
+++ b/lib/fluent/plugin/out_elasticsearch.rb | ||
@@ -651,6 +651,14 @@ EOC | ||
end | ||
end | ||
|
||
+ def is_ipv6_host(host_str) | ||
+ begin | ||
+ IPAddr.new(host_str).ipv6? | ||
+ rescue IPAddr::InvalidAddressError | ||
+ return false | ||
+ end | ||
+ end | ||
+ | ||
def get_connection_options(con_host=nil) | ||
|
||
hosts = if con_host || @hosts | ||
@@ -662,6 +670,21 @@ EOC | ||
port: (host_str.split(':')[1] || @port).to_i, | ||
scheme: @scheme.to_s | ||
} | ||
+ # Support ipv6 for host/host placeholders | ||
+ elsif is_ipv6_host(host_str) | ||
+ if Resolv::IPv6::Regex.match(host_str) | ||
+ { | ||
+ host: "[#{host_str}]", | ||
+ port: @port.to_i, | ||
+ scheme: @scheme.to_s | ||
+ } | ||
+ else | ||
+ { | ||
+ host: host_str, | ||
+ port: @port.to_i, | ||
+ scheme: @scheme.to_s | ||
+ } | ||
+ end | ||
else | ||
# New hosts format expects URLs such as http://logs.foo.com,https://john:pass@logs2.foo.com/elastic | ||
uri = URI(get_escaped_userinfo(host_str)) |