Reputation: 11
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
Upvotes: 1
Views: 2801
Reputation: 5274
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.
<system>
"#{MONGO_CONNECTION_STRING='mongodb://localhost:27017/test'}"
</system>
<match>
@type mongo
connection_string "#{MONGO_CONNECTION_STRING}"
# database test
collection fluentd
</match>
Upvotes: 0
Reputation: 2855
You need to make sure that the /etc/sysconfig/td-agent
have execute rights
chmod a+x /etc/sysconfig/td-agen
and 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
TD_AGENT_DEFAULT=/etc/sysconfig/td-agent
# Read configuration variable file if it is present
if [ -f "${TD_AGENT_DEFAULT}" ]; then
. "${TD_AGENT_DEFAULT}"
fi
Upvotes: 0