Fluentd
1.0
1.0
  • Introduction
  • Overview
    • Life of a Fluentd event
    • Support
    • FAQ
    • Logo
    • fluent-package v5 vs td-agent v4
  • Installation
    • Before Installation
    • Install fluent-package
      • RPM Package (Red Hat Linux)
      • DEB Package (Debian/Ubuntu)
      • .dmg Package (macOS)
      • .msi Installer (Windows)
    • Install calyptia-fluentd
      • RPM Package (Red Hat Linux)
      • DEB Package (Debian/Ubuntu)
      • .dmg Package (macOS)
      • .msi Installer (Windows)
    • Install by Ruby Gem
    • Install from Source
    • Post Installation Guide
    • Obsolete Installation
      • Treasure Agent v4 (EOL) Installation
        • Install by RPM Package v4 (Red Hat Linux)
        • Install by DEB Package v4 (Debian/Ubuntu)
        • Install by .dmg Package v4 (macOS)
        • Install by .msi Installer v4 (Windows)
      • Treasure Agent v3 (EOL) Installation
        • Install by RPM Package v3 (Red Hat Linux)
        • Install by DEB Package v3 (Debian/Ubuntu)
        • Install by .dmg Package v3 (macOS)
        • Install by .msi Installer v3 (Windows)
  • Configuration
    • Config File Syntax
    • Config File Syntax (YAML)
    • Routing Examples
    • Config: Common Parameters
    • Config: Parse Section
    • Config: Buffer Section
    • Config: Format Section
    • Config: Extract Section
    • Config: Inject Section
    • Config: Transport Section
    • Config: Storage Section
    • Config: Service Discovery Section
  • Deployment
    • System Configuration
    • Logging
    • Signals
    • RPC
    • High Availability Config
    • Performance Tuning
    • Multi Process Workers
    • Failure Scenarios
    • Plugin Management
    • Trouble Shooting
    • Fluentd UI
    • Linux Capability
    • Command Line Option
    • Source Only Mode
    • Zero-downtime restart
  • Container Deployment
    • Docker Image
    • Docker Logging Driver
    • Docker Compose
    • Kubernetes
  • Monitoring Fluentd
    • Overview
    • Monitoring by Prometheus
    • Monitoring by REST API
  • Input Plugins
    • tail
    • forward
    • udp
    • tcp
    • unix
    • http
    • syslog
    • exec
    • sample
    • monitor_agent
    • windows_eventlog
  • Output Plugins
    • file
    • forward
    • http
    • exec
    • exec_filter
    • secondary_file
    • copy
    • relabel
    • roundrobin
    • stdout
    • null
    • s3
    • kafka
    • elasticsearch
    • opensearch
    • mongo
    • mongo_replset
    • rewrite_tag_filter
    • webhdfs
    • buffer
  • Filter Plugins
    • record_transformer
    • grep
    • parser
    • geoip
    • stdout
  • Parser Plugins
    • regexp
    • apache2
    • apache_error
    • nginx
    • syslog
    • ltsv
    • csv
    • tsv
    • json
    • msgpack
    • multiline
    • none
  • Formatter Plugins
    • out_file
    • json
    • ltsv
    • csv
    • msgpack
    • hash
    • single_value
    • stdout
    • tsv
  • Buffer Plugins
    • memory
    • file
    • file_single
  • Storage Plugins
    • local
  • Service Discovery Plugins
    • static
    • file
    • srv
  • Metrics Plugins
    • local
  • How-to Guides
    • Stream Analytics with Materialize
    • Send Apache Logs to S3
    • Send Apache Logs to Minio
    • Send Apache Logs to Mongodb
    • Send Syslog Data to Graylog
    • Send Syslog Data to InfluxDB
    • Send Syslog Data to Sematext
    • Data Analytics with Treasure Data
    • Data Collection with Hadoop (HDFS)
    • Simple Stream Processing with Fluentd
    • Stream Processing with Norikra
    • Stream Processing with Kinesis
    • Free Alternative To Splunk
    • Email Alerting like Splunk
    • How to Parse Syslog Messages
    • Cloud Data Logging with Raspberry Pi
  • Language Bindings
    • Java
    • Ruby
    • Python
    • Perl
    • PHP
    • Nodejs
    • Scala
  • Plugin Development
    • How to Write Input Plugin
    • How to Write Base Plugin
    • How to Write Buffer Plugin
    • How to Write Filter Plugin
    • How to Write Formatter Plugin
    • How to Write Output Plugin
    • How to Write Parser Plugin
    • How to Write Storage Plugin
    • How to Write Service Discovery Plugin
    • How to Write Tests for Plugin
    • Configuration Parameter Types
    • Upgrade Plugin from v0.12
  • Plugin Helper API
    • Plugin Helper: Child Process
    • Plugin Helper: Compat Parameters
    • Plugin Helper: Event Emitter
    • Plugin Helper: Event Loop
    • Plugin Helper: Extract
    • Plugin Helper: Formatter
    • Plugin Helper: Inject
    • Plugin Helper: Parser
    • Plugin Helper: Record Accessor
    • Plugin Helper: Server
    • Plugin Helper: Socket
    • Plugin Helper: Storage
    • Plugin Helper: Thread
    • Plugin Helper: Timer
    • Plugin Helper: Http Server
    • Plugin Helper: Service Discovery
  • Troubleshooting Guide
  • Appendix
    • Update from v0.12 to v1
    • td-agent v2 vs v3 vs v4
Powered by GitBook
On this page
  • fluent-gem
  • Do not use unreliable plugins
  • If Using td-agent, Use /usr/sbin/td-agent-gem
  • Gem and Native Extension
  • -p option
  • Add a Plugin via /etc/fluent/plugin
  • If Using td-agent, Use /etc/td-agent/plugin
  • Plugin Version Management
  • --gemfile option
  • For td-agent
  • FAQ
  • fluent-gem list shows multiple plugin versions. Which one is used?

Was this helpful?

  1. Deployment

Plugin Management

This article explains how to manage Fluentd plugins, including adding third-party plugins.

fluent-gem

The fluent-gem command is used to install Fluentd plugins. This is a wrapper around the gem command.

Example:

fluent-gem install fluent-plugin-grep

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

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:

Building native extensions.  This could take a while...
ERROR:  Error installing fluent-plugin-twitter:
        ERROR: Failed to build gem native extension.

    /opt/td-agent/embedded/bin/ruby extconf.rb

checking for rb_str_scrub()... yes
creating Makefile

make "DESTDIR = " clean
sh: 1: make: not found

make "DESTDIR = "
sh: 1: make: not found

make failed, exit code 127

Gem files will remain installed in /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/string-scrub-0.0.3 for inspection.
Results logged to /opt/td-agent/embedded/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0/string-scrub-0.0.3/gem_make.out

-p option

Fluentd'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:

fluentd -p /path/to/plugin

You can specify the -p option more than once.

Add a Plugin via /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

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

For example, if you have the following Gemfile at /etc/fluent/Gemfile:

source 'https://rubygems.org'

gem 'fluentd', '1.2.1'
gem 'fluent-plugin-elasticsearch', '2.10.3'

You can pass this Gemfile to Fluentd via the --gemfile option:

fluentd --gemfile /etc/fluent/Gemfile

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

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:

[Service]
Environment='TD_AGENT_OPTIONS=--gemfile=/etc/td-agent/Gemfile --gem-path=/var/lib/td-agent/vendor/bundle'
ExecStart=
ExecStart=/opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td-agent/td-agent.pid $TD_AGENT_OPTIONS

We can also edit this file using the following command:

$ sudo systemctl edit td-agent.service

And, then add /etc/td-agent/Gemfile:

source "https://rubygems.org"
# You can use fixed version of Fluentd and its plugins
gem "fluentd", "1.2.1"
gem "fluent-plugin-elasticsearch", "2.4.0"
gem "fluent-plugin-kafka", "0.6.5"
gem "fluent-plugin-rewrite-tag-filter", "2.0.1"
gem "fluent-plugin-s3", "1.1.0"
gem "fluent-plugin-td", "1.0.0"
gem "fluent-plugin-td-monitoring", "0.2.3"
gem "fluent-plugin-webhdfs", "1.2.2"
# Add plugins you want to use
gem "fluent-plugin-geoip", "1.2.0"

Finally, restart td-agent:

$ sudo systemctl restart td-agent.service

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?

The latest version is used. If command shows the following result:

$ fluent-gem list
...skip...
fluent-plugin-record-modifier (2.0.1, 0.6.0, 0.5.0)

2.0.1 version is used.

PreviousFailure ScenariosNextTrouble Shooting

Last updated 3 years ago

Was this helpful?

A Ruby application manages gem dependencies using Gemfile and . Fluentd's --gemfile option takes the same approach, and is useful for managing plugin versions separated from shared gems.

If this article is incorrect or outdated, or omits critical information, please . is an open-source project under . All components are available under the Apache 2 License.

Bundler
let us know
Fluentd
Cloud Native Computing Foundation (CNCF)