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

tail new multiline support(fluentbit must be later than V1.8) #172

Merged
merged 1 commit into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
with:
fetch-depth: 0

- name: Go mod
run: |
export PATH=$PATH:$(go env GOPATH)/bin
go mod download

- name: Install kubebuilder-3.1.0
run: |
curl -L -o kubebuilder "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v3.1.0/kubebuilder_linux_amd64"
Expand Down
6 changes: 6 additions & 0 deletions api/fluentbitoperator/v1alpha2/plugins/input/tail_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type Tail struct {
DockerModeFlushSeconds *int64 `json:"dockerModeFlushSeconds,omitempty"`
// DisableInotifyWatcher will disable inotify and use the file stat watcher instead.
DisableInotifyWatcher *bool `json:"disableInotifyWatcher,omitempty"`
// This will help to reassembly multiline messages originally split by Docker or CRI
//Specify one or Multiline Parser definition to apply to the content.
MultilineParser string `json:"multilineParser,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not an appropriate practice to define MultilineParser as a string.

What if the parameter multiline.xxx is added later?

Maybe a struct is more reasonable.

type Multiline struct {
  Parser string
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. But there is the multiline property in the old property.

	// If enabled, the plugin will try to discover multiline messages
	// and use the proper parsers to compose the outgoing messages.
	// Note that when this option is enabled the Parser option is not used.
	Multiline *bool `json:"multiline,omitempty"`

And after testing, and if a structure is added, the following input is required for the user

DB:
      sync: xx

Not like the original

dbSync: xxx

The original configuration file is more similar to fluent-bit itself

}

func (_ *Tail) Name() string {
Expand Down Expand Up @@ -167,5 +170,8 @@ func (t *Tail) Params(_ plugins.SecretLoader) (*params.KVs, error) {
if t.DisableInotifyWatcher != nil {
kvs.Insert("Inotify_Watcher", fmt.Sprint(!*t.DisableInotifyWatcher))
}
if t.MultilineParser != "" {
kvs.Insert("multiline.parser", t.MultilineParser)
}
return kvs, nil
}
18 changes: 18 additions & 0 deletions conf/parsers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,24 @@
Time_Keep On
Time_Key time

[MULTILINE_PARSER]
name multiline-regex-test
type regex
flush_timeout 1000
#
# Regex rules for multiline parsing
# ---------------------------------
#
# configuration hints:
#
# - first state always has the name: start_state
# - every field in the rule must be inside double quotes
#
# rules | state name | regex pattern | next state
# ------|---------------|--------------------------------------------
rule "start_state" "/(Dec \d+ \d+\:\d+\:\d+)(.*)/" "cont"
rule "cont" "/^\s+at.*/" "cont"

[PARSER]
# https://rubular.com/r/3fVxCrE5iFiZim
Name envoy
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/logging.kubesphere.io_inputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ spec:
messages
format: int64
type: integer
multilineParser:
description: This will help to reassembly multiline messages originally
split by Docker or CRI Specify one or Multiline Parser definition
to apply to the content.
type: string
parser:
description: Specify the name of a parser to interpret the entry
as a structured message.
Expand Down
5 changes: 5 additions & 0 deletions manifests/setup/fluentbit-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3315,6 +3315,11 @@ spec:
messages
format: int64
type: integer
multilineParser:
description: This will help to reassembly multiline messages originally
split by Docker or CRI Specify one or Multiline Parser definition
to apply to the content.
type: string
parser:
description: Specify the name of a parser to interpret the entry
as a structured message.
Expand Down
5 changes: 5 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3320,6 +3320,11 @@ spec:
messages
format: int64
type: integer
multilineParser:
description: This will help to reassembly multiline messages originally
split by Docker or CRI Specify one or Multiline Parser definition
to apply to the content.
type: string
parser:
description: Specify the name of a parser to interpret the entry
as a structured message.
Expand Down