I have problem with using env at td-agent config, I tried:
<source>
@type tail
path /home/td-agent/test.txt
tag "#{ENV['WEBTEST']}"
pos_file /var/log/td-agent/td-agent-test.pos
@include /etc/td-agent/web_parse_regex.conf
</source>
/etc/sysconfig/td-agent :
export WEBTEST="webtest"
and when I start td-agent and check td-agent.log, tag is empty
2020-06-09 15:40:20 +0900 [info]: using configuration file: <ROOT>
<source>
@type tail
path "/home/td-agent/test.txt"
tag ""
pos_file "/var/log/td-agent/td-agent-test.pos"
.....
+I’m using centos
2
Answers
You need to make sure that the
/etc/sysconfig/td-agent
have execute rightsand to make sure that the init script is executing these files, the below lines need to be in the file
/etc/init.d/td-agent
could not find a way to set env vars from inside the conf file, but you can set variable values in ruby in the
system
blocks and reuse them in the conf file.