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

[WIP] feat: add multiline parser support for fluentbit #842

Closed
wants to merge 7 commits into from

Conversation

ksdpmx
Copy link
Collaborator

@ksdpmx ksdpmx commented Jul 23, 2023

What this PR does / why we need it:

currently users cannot setup custom multiline parser via operator.
and there're many unsupported fields for multiline parser in filter

Which issue(s) this PR fixes:

Fixes #176 and #336

  1. add more fields for multiline parser in filter (add multiline filter plugin #176)
  2. add ClusterMultilineParser and MultilineParser crd for multiline parser (help request: multiline settings don't work? #336)

Does this PR introduced a user-facing change?

feat: add multiline parser support for fluentbit

Additional documentation, usage docs, etc.:


@ksdpmx ksdpmx changed the title feat: add multiline parser support for fluentbit [WIP] feat: add multiline parser support for fluentbit Jul 23, 2023
// +genclient:nonNamespaced

// ClusterMultilineParser is the Schema for the cluster-level multiline parser API
type ClusterMultilineParser struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why need to create a new CRD? I think multiline Parser is also a kind of Parser, it can use Parser CRD.

Copy link
Collaborator Author

@ksdpmx ksdpmx Jul 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. the section for multiline parser is [MULTILINE_PARSER] instead of [PARSER]
  2. multiline parser is not located under Parsers in fluentbit doc

i agree with the idea that it's better to treat multiline parser as one kind of parsers as well.

but it seems like currently it's not implemented like this from fluentbit's perspective. it's also reasonable to follow the convention of fluentbit so that customers won't get confused.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it.

Does it need to add the parsers_multiline.conf to the SERVER section?

1690248036164

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. so i propose to add one new field called parsersFiles to support multiple parsers_file in SERVICE section, and keep parsersFile for backward compatibility: https://github.com/fluent/fluent-operator/pull/842/files#diff-7aad9bf9eeeaa93f3a61c5ea93ea5a30d57bcfa6307ec4ea188222fdf69f438cR180 in case customers want to add parsers.conf and parsers_multiline.conf at the same time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wanjunlei would you review this again?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how to set the ClusterFluentBitConfig when I define a MultilineParser and want to use it?

Copy link
Collaborator Author

@ksdpmx ksdpmx Aug 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for the late reply. i'll have an E2E test tomorrow.

Copy link
Collaborator Author

@ksdpmx ksdpmx Aug 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. fix rbac for new crd
  2. inline for MultilineParser

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to set the ClusterFluentBitConfig when I define a MultilineParser and want to use it

apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterFluentBitConfig
metadata:
  labels:
    app.kubernetes.io/name: fluent-bit
  name: fluent-bit-config
spec:
  filterSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"
  inputSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"
  multilineparserSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"
  outputSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"
  parserSelector:
    matchLabels:
      fluentbit.fluent.io/enabled: "true"
  service:
    logLevel: info
    parsersFile: parsers_multiline.conf
apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterMultilineParser
metadata:
  labels:
    fluentbit.fluent.io/component: logging
    fluentbit.fluent.io/enabled: "true"
  name: stacktrace
spec:
  flushTimeout: 1000
  rules:
  - next: cont
    regex: /([a-zA-Z]+ \d+ \d+\:\d+\:\d+)(.*)/
    start: start_state
  - next: cont
    regex: /^\s+at.*/
    start: cont
  type: regex

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, the parsersFile in ClusterFluentBitConfig is parsers.conf, And it points to /fluent-bit/etc/parsers.conf which include the common parsers such as docker, cri. If it was set to parsers_multiline.conf, the fluentbit cannot find these parsers.

BTW, if the parsersFile in ClusterFluentBitConfig is a relative path, the fluentbit will find it in the directory where the fluentbit configuration file is located, which is /fluent-bit/etc/, but the parsers_multiline.conf is in /fluent-bit/config/.

Maybe you should handle the parsers_multiline.conf like parsers.conf

企业微信截图_16913732558404

@ksdpmx ksdpmx requested a review from wanjunlei July 24, 2023 11:21
@ksdpmx ksdpmx force-pushed the multiline_parser branch 3 times, most recently from 1382b7a to 2b0bbbc Compare July 30, 2023 05:36
@@ -41,6 +41,8 @@ type FluentBitConfigSpec struct {
OutputSelector metav1.LabelSelector `json:"outputSelector,omitempty"`
// Select parser plugins
ParserSelector metav1.LabelSelector `json:"parserSelector,omitempty"`
// Select multiline parser plugins
MultilineParserSelector metav1.LabelSelector `json:"multilineparserSelector,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
MultilineParserSelector metav1.LabelSelector `json:"multilineparserSelector,omitempty"`
MultilineParserSelector metav1.LabelSelector `json:"multilineParserSelector,omitempty"`

@benjaminhuo
Copy link
Member

@ksdpmx Hi Jason, would you resolve the conflicts and conversation remains?

@ksdpmx
Copy link
Collaborator Author

ksdpmx commented Aug 28, 2023

@ksdpmx Hi Jason, would you resolve the conflicts and conversation remains?

@benjaminhuo sure will check this weekend. sorry for the late reply. quite busy recently:(

@americans007
Copy link

@ksdpmx looking forward multiline feature, could you please find time to resolve conflicts.

@JoeDerby
Copy link
Contributor

JoeDerby commented Dec 7, 2023

@ksdpmx Do you have any updates when you will have time to resolve these conflicts, this is a feature I would be very interested also. Thanks.

@ksdpmx
Copy link
Collaborator Author

ksdpmx commented Dec 9, 2023

thanks for the patience and understanding.. I've had some free time this month. continuing the remaining work.. :(

@pikodd
Copy link

pikodd commented Dec 19, 2023

Hi, @ksdpmx do you need any help with this task?
We really need this feature and we would like help you resolving it.

@esperoz
Copy link

esperoz commented Jan 9, 2024

Hi, @ksdpmx! Also interested in this feature. How can I help you?

ksdpmx and others added 4 commits January 9, 2024 15:34
Signed-off-by: jasonz <ksdpmx@gmail.com>
Signed-off-by: Alex Krasnov <askrasnov@gmail.com>
Signed-off-by: Alex Krasnov <askrasnov@gmail.com>
@esperoz
Copy link

esperoz commented Jan 12, 2024

Hi everybody!
@ksdpmx, would you be so kind to review and accept PR to your repo ksdpmx#1 with fixes:

  • Adjusted multilineparserSelector to multilineParserSelector as of comment @benjaminhuo
  • Added watches for ClusterMultilineParser and MultilineParser
  • Fixed inline import in MultilineParserSpec
  • Rebased to fluent:master
    Checked with our team - it works. If something need to be fixed, please let me know.

@wenchajun
Copy link
Member

Hi everybody! @ksdpmx, would you be so kind to review and accept PR to your repo ksdpmx#1 with fixes:

  • Adjusted multilineparserSelector to multilineParserSelector as of comment @benjaminhuo
  • Added watches for ClusterMultilineParser and MultilineParser
  • Fixed inline import in MultilineParserSpec
  • Rebased to fluent:master
    Checked with our team - it works. If something need to be fixed, please let me know.

I think you can resubmit a pull request to this repository. There are too many commits here, which makes it a bit confusing. After reviewing the code, I noticed that you are treating 'multiline' as a resource to watch, and I don't think it's the best approach in this regard (it could be my misunderstanding). I suggest you submit a pull request so that we can discuss and explore alternative solutions together."

@elsnepal
Copy link

@ksdpmx are you able to look at this? :)

@ksdpmx
Copy link
Collaborator Author

ksdpmx commented Mar 30, 2024

some internal team is also interested in this feature.. allow me few hours to catch with the context this time..

@ksdpmx ksdpmx force-pushed the multiline_parser branch 3 times, most recently from 8d3f00d to e6e7b19 Compare March 30, 2024 04:05
@ksdpmx ksdpmx force-pushed the multiline_parser branch 2 times, most recently from 97d0608 to e0c5675 Compare March 30, 2024 04:34
Signed-off-by: jasonz <ksdpmx@gmail.com>
Merge pull request #1 from shturval-tech/multiline_parser

Signed-off-by: jasonz <ksdpmx@gmail.com>
@ksdpmx
Copy link
Collaborator Author

ksdpmx commented Mar 30, 2024

I think you can resubmit a pull request to this repository. There are too many commits here, which makes it a bit confusing.

  • two commits w/o sign-off
  • two rebases which makes it hard to squash
  • too many commits for this legacy PR

so here's the new one #1100.
@esperoz please submit another new one if there's any concern about this PR. i'm fine with the ownership of it :)

@benjaminhuo
Copy link
Member

Finished in #1100, close this for now

@benjaminhuo benjaminhuo closed this Apr 6, 2024
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

Successfully merging this pull request may close these issues.

9 participants