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

add multiline filter plugin #176

Merged
merged 1 commit into from
Dec 1, 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ The list below shows supported plugins which are based on Fluent Bit v1.7.x+. Fo
- [lua](docs/plugins/filter/lua.md)
- [throttle](docs/plugins/filter/throttle.md)
- [aws](docs/plugins/filter/aws.md)
- [multiline](docs/plugins/filter/multiline.md)
- [Output](docs/crd.md#output)
- [elasticsearch](docs/plugins/output/elasticsearch.md)
- [file](docs/plugins/output/file.md)
Expand Down
2 changes: 2 additions & 0 deletions api/fluentbitoperator/v1alpha2/filter_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ type FilterItem struct {
RewriteTag *filter.RewriteTag `json:"rewriteTag,omitempty"`
//Aws defines a Aws configuration.
AWS *filter.AWS `json:"aws,omitempty"`
//Multiline defines a Multiline configuration.
Multiline *filter.Multiline `json:"multiline,omitempty"`
}

// +kubebuilder:object:root=true
Expand Down
40 changes: 40 additions & 0 deletions api/fluentbitoperator/v1alpha2/plugins/filter/multiline_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package filter

import (
"kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins"
"kubesphere.io/fluentbit-operator/api/fluentbitoperator/v1alpha2/plugins/params"
)

// +kubebuilder:object:generate:=true

// The Multiline Filter helps to concatenate messages that originally belong to one context but were split across multiple records or log lines.
type Multiline struct {
// The Inline struct helps to concatenate messages that originally belong to one context but were split across multiple records or log lines.
*Multi `json:",inline"`
}

type Multi struct {
// Specify one or multiple Multiline Parsing definitions to apply to the content.
//You can specify multiple multiline parsers to detect different formats by separating them with a comma.
Parser string `json:"parser"`
//Key name that holds the content to process.
//Note that a Multiline Parser definition can already specify the key_content to use, but this option allows to overwrite that value for the purpose of the filter.
KeyContent string `json:"keyContent,omitempty"`
}

func (_ *Multiline) Name() string {
return "multiline"
}

func (m *Multiline) Params(_ plugins.SecretLoader) (*params.KVs, error) {
kvs := params.NewKVs()
if m.Multi != nil {
if m.Multi.Parser != "" {
kvs.Insert("multiline.parser", m.Multi.Parser)
}
if m.Multi.KeyContent != "" {
kvs.Insert("multiline.key_content", m.Multi.KeyContent)
}
}
return kvs, nil
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions api/fluentbitoperator/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions config/crd/bases/logging.kubesphere.io_filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,24 @@ spec:
type: object
type: array
type: object
multiline:
description: Multiline defines a Multiline configuration.
properties:
keyContent:
description: Key name that holds the content to process.
Note that a Multiline Parser definition can already specify
the key_content to use, but this option allows to overwrite
that value for the purpose of the filter.
type: string
parser:
description: Specify one or multiple Multiline Parsing definitions
to apply to the content. You can specify multiple multiline
parsers to detect different formats by separating them
with a comma.
type: string
required:
- parser
type: object
nest:
description: Nest defines Nest Filter configuration.
properties:
Expand Down
9 changes: 9 additions & 0 deletions docs/plugins/filter/multiline.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Multiline

The Multiline Filter helps to concatenate messages that originally belong to one context but were split across multiple records or log lines. Common examples are stack traces or applications that print logs in multiple lines.


| Field | Description | Scheme |Default|
| ----- | ----------- | ------ | -----|
| multiline.parser | Specify one or multiple Multiline Parser definitions to apply to the content. You can specify multiple multiline parsers to detect different formats by separating them with a comma. | string ||
| multiline.key_content| Key name that holds the content to process. Note that a Multiline Parser definition can already specify the key_content to use, but this option allows to overwrite that value for the purpose of the filter. | string ||
18 changes: 18 additions & 0 deletions manifests/setup/fluentbit-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,24 @@ spec:
type: object
type: array
type: object
multiline:
description: Multiline defines a Multiline configuration.
properties:
keyContent:
description: Key name that holds the content to process.
Note that a Multiline Parser definition can already specify
the key_content to use, but this option allows to overwrite
that value for the purpose of the filter.
type: string
parser:
description: Specify one or multiple Multiline Parsing definitions
to apply to the content. You can specify multiple multiline
parsers to detect different formats by separating them
with a comma.
type: string
required:
- parser
type: object
nest:
description: Nest defines Nest Filter configuration.
properties:
Expand Down
18 changes: 18 additions & 0 deletions manifests/setup/setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,24 @@ spec:
type: object
type: array
type: object
multiline:
description: Multiline defines a Multiline configuration.
properties:
keyContent:
description: Key name that holds the content to process.
Note that a Multiline Parser definition can already specify
the key_content to use, but this option allows to overwrite
that value for the purpose of the filter.
type: string
parser:
description: Specify one or multiple Multiline Parsing definitions
to apply to the content. You can specify multiple multiline
parsers to detect different formats by separating them
with a comma.
type: string
required:
- parser
type: object
nest:
description: Nest defines Nest Filter configuration.
properties:
Expand Down