EDIT:
Here is a much better solution:
If you pass the "-use-v1-config" flag to Fluentd, this is possible with "# {ENV ['env_var_name']" something like this:
<match foobar.**> # ENV["FOO"] is foobar type elasticsearch logstash_prefix "#{ENV['FOO']}" logstash_format true include_tag_key true tag_key _key host **** port **** </match>
The old, kludgey answer is here.
- Install
fluent-plugin-record-reformer and fluent-plugin-forest - Update the configuration as follows.
<match hello.world> type record_reformer tag ${ENV["FOO"]}.${tag_prefix[-1]} # adding the env variable as a tag prefix </match> <match foobar.**> # ENV["FOO"] is foobar type forest subtype elasticsearch <template> logstash_prefix ${tag_parts[0]} logstash_format true include_tag_key true tag_key _key host **** port **** </template> </match>
In particular, DO NOT use <match **> there. This will capture all events and lead to behavior that is difficult to debug.
source share