Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record Modifer on Windows Server doesn't execute Ruby code #72

Open
JPGrieb opened this issue Jun 13, 2023 · 2 comments
Open

Record Modifer on Windows Server doesn't execute Ruby code #72

JPGrieb opened this issue Jun 13, 2023 · 2 comments

Comments

@JPGrieb
Copy link

JPGrieb commented Jun 13, 2023

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?

@daipom
Copy link

daipom commented Jun 14, 2023

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>

@repeatedly
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants