Plugin Management
This article explains how to manage Fluentd plugins, including adding third-party plugins.
fluent-gem
fluent-gem
The fluent-gem
command is used to install Fluentd plugins. This is a wrapper around the gem
command.
Example:
Ruby does not guarantee the C extension API compatibility between its major versions. If you update Fluentd's Ruby version, you should reinstall the plugins that depend on C extension.
Do not use unreliable plugins
Any fluentd plugin can unknowingly break fluentd completely (and possibly break other plugins) by requiring some incompatible modules.
There is no way to block this kind of situation. This is because the problem itself is derived from plug-in mechanism, and that's Lightweight Language. One solution is "Do not use unreliable plugins".
Generally speaking, plug-in mechanism can break core functionality not only Fluentd but also in most other software. We shouldn't use unreliable plugins in any software.
We recommend to send feedback to plugin owner if you faced such a fault in plugins.
If Using td-agent
, Use /usr/sbin/td-agent-gem
td-agent
, Use /usr/sbin/td-agent-gem
If you are using td-agent
, make sure that you use td-agent-gem
command to install gems for it. Otherwise, you won't be able to find the installed plugins.
Gem and Native Extension
Some plugins depend on the native extension library. It means that you need to install development packages to build it e.g. gcc
, make
, autoconf
, etc.
Install development packages first, if you see logs like this:
-p
option
-p
optionFluentd's -p
option is used to add an extra plugin directory to the load path. For example, if you put out_foo.rb
plugin into /path/to/plugin
, you can load it by specifying the -p
option like this:
You can specify the -p
option more than once.
Add a Plugin via /etc/fluent/plugin
/etc/fluent/plugin
By default, Fluentd adds the /etc/fluent/plugin
directory to its load path. Thus, any additional plugins that are placed in /etc/fluent/plugin
will be loaded automatically.
If Using td-agent
, Use /etc/td-agent/plugin
td-agent
, Use /etc/td-agent/plugin
For td-agent
, Fluentd uses the /etc/td-agent/plugin
directory instead of /etc/fluent/plugin
so put your plugins accordingly.
Plugin Version Management
Fluentd and plugins are evolving so you may hit an unexpected error with the latest version e.g. regression by a new feature, remove a deprecated parameter, change library dependency, etc. To avoid these problems, we recommend fixing fluentd and plugin version on production. If you want to update fluentd or plugins, check the behavior first on your test environment. For example, td-agent fixes fluentd and plugins version in each release.
Fluentd plugins are RubyGems and RubyGems installs the latest version by default. So we don't recommend to execute following commands on production:
gem install fluentd
gem install fluent-plugin-elasticsearch
gem update # This is very dangerous. Update all existing gems
You should specify the target version with -v
option:
gem install fluentd -v 1.2.1
gem install fluent-plugin-elasticsearch -v 2.10.3
--gemfile
option
--gemfile
optionA Ruby application manages gem dependencies using Gemfile and Bundler
. Fluentd's --gemfile
option takes the same approach, and is useful for managing plugin versions separated from shared gems.
For example, if you have the following Gemfile at /etc/fluent/Gemfile
:
You can pass this Gemfile to Fluentd via the --gemfile
option:
When specifying the --gemfile
option, Fluentd will try to install the listed gems using Bundler. Fluentd will only load the listed gems separated from shared gems, and will also prevent unexpected plugin updates.
If you update Fluentd's Ruby version, Bundler will reinstall the listed gems for the new Ruby version. This allows you to avoid the C extension API compatibility problem.
For td-agent
td-agent
We can manage Fluentd and its plugins based on Gemfile with td-agent
.
Use the following drop-in file /etc/systemd/system/td-agent.service.d/override.conf
for td-agent
3.1.1:
We can also edit this file using the following command:
And, then add /etc/td-agent/Gemfile
:
Finally, restart td-agent
:
NOTE: With this approach, you will download all the gems listed in Gemfile even if td-agent
includes them the first time.
FAQ
fluent-gem list
shows multiple plugin versions. Which one is used?
fluent-gem list
shows multiple plugin versions. Which one is used?The latest version is used. If command shows the following result:
2.0.1
version is used.
If this article is incorrect or outdated, or omits critical information, please let us know. Fluentd is an open-source project under Cloud Native Computing Foundation (CNCF). All components are available under the Apache 2 License.
Last updated