fluent-plugin-record-modifier icon indicating copy to clipboard operation
fluent-plugin-record-modifier copied to clipboard

Record Modifer on Windows Server doesn't execute Ruby code

Open JPGrieb opened this issue 1 year ago • 2 comments

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?

JPGrieb avatar Jun 13 '23 22:06 JPGrieb

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>

daipom avatar Jun 14 '23 01:06 daipom

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

repeatedly avatar Jun 14 '23 09:06 repeatedly