y-ken/fluent-plugin-mysql-query

Support mutil mysql host ?

anfengdaydayup opened this issue · 1 comments

Whether to support mutil mysql host ?
like host 10.11.50.164,10.11.50.160,...
thanks

Hi.

To support multiple mysql host, you can use another plugin fluent-plugin-config-expander together.
It will work for you with following example configuration.

Prepare

install with gem or fluent-gem command as:

# for fluentd
$ gem install fluent-plugin-config-expander

# for td-agent
$ sudo /usr/lib64/fluent/ruby/bin/fluent-gem install fluent-plugin-config-expander

Example

Using fluent-plugin-config-expander

<source>
  type config_expander
  <config>
    type mysql_query
    query SELECT foo FROM bar;
    <for server in 164 160 155>
      host 10.11.50.__server__
      tag mysqlstat.s__server__ # Outputs: mysqlstat.s164, mysqlstat.s160, mysqlstat.s155
    </for>
  </config>
</source>

<match mysqlstat.*>
  type stdout
</match>

Thank you for your good question.