Fluentbit中Match插件的正则表达式支持用于过滤器插件

huangapple go评论105阅读模式
英文:

Fluentbit Regex support in Match for Filter plugins

问题

  1. 它只支持基本的通配符支持还是完整的正则表达式支持?
  2. 在节流插件中是否有办法实现我正在尝试做的事情?
英文:

I have a basic question about the usage of Match for Filter plugins.
I saw that Match supports wildcard, based on https://docs.fluentbit.io/manual/concepts/data-pipeline/router
Is it only basic wildcard support or complete regex support?
My typical tags look like part1.part2.part3.part4

This is my current configuration and it works as expected (i.e. logs that match these tags are getting throttled).

    [FILTER]
        Name                      throttle
        Match                     part1.*.*.part4
        Rate                      1
        Window                    300
        Interval                  1s

I tried to modify this so that this filter is not applied if part2=xyz

    [FILTER]
        Name                      throttle
        Match                     part1.(?!xyz).*.part4
        Rate                      1
        Window                    300
        Interval                  1s

But looks like this isn't working (i.e. none of the logs are getting throttled)

My questions:

  1. Does it only support basic wildcard support or has complete regex support?
  2. Is there a way to do what I am trying to do in the throttle plugin?

答案1

得分: 0

发现答案

TIL:有一个名为Match_Regex的关键字,它可以在所有可以使用Match的地方使用。
Match仅支持*作为通配符。
Match_Regex支持完整的正则表达式。

来源:https://docs.fluentbit.io/manual/v/1.3/configuration/file

我的修改后的配置

[FILTER]
    Name                      throttle
    Match_Regex               part1.(?!xyz).*.part4
    Rate                      1
    Window                    300
    Interval                  1s

感谢Anurag Gupta在Fluentbit Slack中指出这一点。

英文:

Found the answer

TIL: there is a key named Match_Regex and it works in all the places where Match can be used.
Match only support * as a wildcard
Match_Regex supports whole regex

Source: https://docs.fluentbit.io/manual/v/1.3/configuration/file

My modified config

    [FILTER]
        Name                      throttle
        Match_Regex               part1.(?!xyz).*.part4
        Rate                      1
        Window                    300
        Interval                  1s

Thanks to Anurag Gupta for pointing to this in Fluentbit slack.

huangapple
  • 本文由 发表于 2023年7月11日 09:17:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/76658182.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定