out_forward plugin can set targets dynamically via service discovery plugin.#2541
Conversation
87a21da to
d1294ee
Compare
repeatedly
left a comment
There was a problem hiding this comment.
Should we create service_discovery helper for supporting create/configure/manage routines?
|
|
||
| module Fluent | ||
| module Plugin | ||
| class SdFile < ServiceDiscovery |
There was a problem hiding this comment.
Use FileServiceDiscovery better
| ) | ||
| end | ||
| rescue KeyError => e | ||
| raise Fluent::ConfigError, e |
There was a problem hiding this comment.
Maybe, KeyError's error message is not user friendly.
Adding more information is better.
There was a problem hiding this comment.
Added information about what config needs
61a05cd
b3f4ee905
|
|
||
| module Fluent | ||
| module Plugin | ||
| class SdStatic < ServiceDiscovery |
There was a problem hiding this comment.
StaticServiceDiscovery is better
| def configure(conf) | ||
| super | ||
|
|
||
| @services << ServiceDiscovery::Service.new(:static, @host, @port, @name, @weight, @standby, @username, @password, @shared_key) |
There was a problem hiding this comment.
Does this plugin support only one server unlike out_forward?
There was a problem hiding this comment.
Good catch.. changed to be able to handle multiple services.
be04758
| end | ||
| end | ||
|
|
||
| def select_node |
There was a problem hiding this comment.
select_node naming is ok?
This seems out_forward's one. select_service is better than select_node?
There was a problem hiding this comment.
Right. this is out_forward's name. changed to select_service
fixed 9883173 |
| config_param :weight, :integer, default: 60 | ||
| end | ||
|
|
||
| config_section :service_discovery do |
There was a problem hiding this comment.
This define should be done via helper. See parser helper implementation.
| # @param configurations [Hash] hash which must has discivery_service type and its configuration like `{ type: :static, conf: <Fluent::Config::Element> }` | ||
| # @param load_balancer [Object] object which has two methods #rebalance and #select_service | ||
| # @param custom_build_method [Proc] | ||
| def create_service_discovery_manager(title, configurations:, load_balancer: nil, custom_build_method: nil, interval: 3) |
There was a problem hiding this comment.
service_disovery_create_manager is better to follow other plugin helpers.
helpers uses its name as function prefix.
| @_plugin_helper_service_discovery_title = title | ||
| @_plugin_helper_service_discovery_iterval = interval | ||
|
|
||
| @discovery_manager = Fluent::PluginHelper::ServiceDiscovery::Manager.new( |
There was a problem hiding this comment.
unlike other helpers, this helper doesn't allow multiple instance, right?
There was a problem hiding this comment.
You mean multiple @dicovery_mangers? if so, yes.
This manager instance should be one per output/input plugin. the manager has multiple sd plugins.
| module Fluent | ||
| module Plugin | ||
| class ServiceDiscovery # already loaded | ||
| DiscoveryMessage = Struct.new(:type, :service) do |
There was a problem hiding this comment.
Exposing this struct is needed? ServiceDiscovery.service_in/service_out also looks good for me.
With this approach, we can move this implementation into service_discovery.rb and users don't need to require additional file.
|
@cosmo0920 Do you need to review this? You link this PR from elasticsearch plugin. |
|
I'm considering to use service discovery plugin in elasticsearch plugin.
Curently, no. The above link is just a note. |
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
add sd_file Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
if @rr is greater than the size of @weight_array by reducing weight_array number, node can be nil Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
Signed-off-by: Yuta Iwama <ganmacs@gmail.com>
|
Finally merged :) |
|
@ganmacs Could you update fluentd document for service discovery plugin? |
Which issue(s) this PR fixes:
Fixes #756 ?
What this PR does / why we need it:
I Added service_discovery plugin which sets config of servers in out_forwardy dynamically.
In this PR, I supported
sd_fileplugins andsd_staticplugin.sd_file checks the specified file periodically and update its targets.
sd_static is same as
<server>configuration. So the following configurations are completely the same.Docs Changes:
Needed for service discovery plugin.
Release Note:
out_forward plugin can set targets dynamically via service discovery plugin.