rubrikinc / fluent-plugin-throttle

Rate limiting for fluentd
Apache License 2.0
41 stars 24 forks source link

Add support for avoid throttle by fields #8

Open shaikatz opened 5 years ago

shaikatz commented 5 years ago

Hi, First of all, thanks for your great plugin, I find it very useful and powerful.

Our use case requires group records by pod_name + specific log_levels. For example, we want to throttle only records that have log_level warn or error.

Thought that it'll be nice to have an option to specify field and value to prevent the record from being throttled. it can be built like record_modifier does it:

<filter pattern>
  @type record_modifier

  # replace key key1
  <replace>
    # your key name
    key key1
    # your regexp
    expression /^(?<start>.+).{2}(?<end>.+)$/
    # replace string
    replace \\k<start>ors\\k<end>
  </replace>
  # replace key key2
  <replace>
    # your key name
    key key2
    # your regexp
    expression /^(.{1}).{2}(.{1})$/
    # replace string
    replace \\1ors\\2
  </replace>
</filter>

For this plugin we can have:

<ignore_record>
   key log_level
   expression /(info|debug|trace)/
</ignore_record>

What do you think?

shaikatz commented 5 years ago

Since I didn't get any comment about this issue, I've implemented the feature. We currently consider forking the plugin and publishing it as a separate ruby gem since we're in need of this functionality here at my company. Naturally - it will be better to merge this change into your plugin to keep everything in one place, please let me know if this is something you're in favor of too.

g3kr commented 2 years ago

@shaikatz would be able to share what you have done?

shaikatz commented 2 years ago

@g3kr you can find it in my fork https://github.com/shaikatz/fluent-plugin-throttle sorry for the late response.