2014-12-01 19 views

risposta

9

EDIT:

Qui è una soluzione molto migliore:

Se passate "--use-V1-config" per Fluentd, questo è possibile con la "# {ENV [ 'env_var_name' ]" come questo:

<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>

Vecchio, risposta kludgey è qui.

  1. Installare fluent-plugin-record-reformer e fluent-plugin-forest
  2. Aggiornare il config come segue.

<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 particolare, non utilizzare <match **> lì. Ciò catturerebbe tutti gli eventi e condurrebbe a comportamenti difficili da debugare.

+0

Da https://groups.google.com/forum/#!topic/fluentd/z-1vIsQ4kHU è necessario mantenere le variabili di ambiente per --use-v1-config in '/ etc/default/td-agent 'come questo:' export FOO = "foobar" ' – arun

+0

/etc/default/td-agent è per la famiglia debian. Per la famiglia redhat, utilizzare invece/etc/sysconfig/td-agent. – sMiLo

Problemi correlati