I have a source event stream which is coming from a log tail. I'm trying to enrich this by using the filter directive. Some searching mentioned using #{ENV['MYVAR']}
would work but I am getting an empty string as the value. The filter is as below:
<filter logtag.mytag>
@type record_transformer
enable_ruby
<record>
mykey "#{ENV['MYVAR']}"
</record>
</filter>
Is it possible to add an env variable the way I'm doing it, and if so what am I doing incorrectly? Any help is appreciated.
Along with what Imran mentioned (set enable_ruby
to true
), the mistake was that I was using a mac environment and it turns out we have to set the environment variable through launchctl
to make it work instead of exporting it in bash profile or /etc/environment
like we do in linux.
Command:
sudo launchctl setenv MYVAR varvalue
After doing that, it worked right away.