fluent-plugin-record-modifier
fluent-plugin-record-modifier copied to clipboard
Record Modifer on Windows Server doesn't execute Ruby code
I am running the Fluentd agent on Windows Server 2016. I also installed the plug-in "fluent-plugin-grafana-loki" to allow me to output messages to loki. I'm attempting to add the hostname as a label to my messages. I found that when type=file or type=loki, the ruby code in the filter statements below don't work (don't even seem to run):
<match myfile>
@type file
path /var/log/td-agent/access
<label>
host
</label>
</match>
<filter myfile>
@type record_modifier
<record>
host "#{Socket.gethostname}"
</record>
</filter>
<filter myfile>
@type record_modifier
prepare_value require 'socket'; @name = Socket.gethostname
<record>
host ${@name.downcase}
</record>
</filter>
Any suggestions?
I found that when type=file or type=loki, the ruby code in the filter statements below don't work (don't even seem to run):
Do you mean the type of Output plugin?
It is the Input plugin that runs before the Filter plugin. If the Filter plugin is not working, it could be that the tags assigned by the Input plugin do not match, for example. However, it is hard to imagine that it may not work depending on Output plugin.
The following setting works as expected.
<source>
@type sample
tag myfile
</source>
<filter myfile>
@type record_modifier
<record>
host "#{Socket.gethostname}"
</record>
</filter>
<match myfile>
@type stdout
</match>
Maybe, your configuration is something wrong, put filter after match, tag pattern is mismatched and etc. This document shows one not-working example: https://docs.fluentd.org/configuration/config-file#note-on-match-order