Dan*_*cia 8 environment-variables fluentd
我想知道如何在Fluentd配置中使用env vars,我试过:
<match **>
type elasticsearch
logstash_format true
logstash_prefix $ENV_VAR
host ***
port ***
include_tag_key true
tag_key _key
</match>
Run Code Online (Sandbox Code Playgroud)
但它不起作用,任何想法?
Kiy*_*ura 14
编辑:
这是一个更好的解决方案:
如果您将"--use-v1-config"选项传递给Fluentd,则可以使用"#{ENV ['env_var_name']"这样:
<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>Run Code Online (Sandbox Code Playgroud)
旧的,kludgey答案就在这里.
fluent-plugin-record-reformer和fluent-plugin-forest<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>Run Code Online (Sandbox Code Playgroud)
特别是,不要在<match **>那里使用.这将捕获所有事件,并将导致难以调试的行为.
| 归档时间: |
|
| 查看次数: |
6926 次 |
| 最近记录: |