Skip to content

Commit

Permalink
Edit doc. Delete fatal, add warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
george pogosyan committed Jul 30, 2024
1 parent 502f5b9 commit 9a9ef66
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 48 deletions.
42 changes: 42 additions & 0 deletions plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,48 @@ It parses string from the event field using re2 expression with named subgroups
[More details...](plugin/action/parse_re2/README.md)
## remove_fields
It removes the list of the event fields and keeps others.
Nested fields supported: list subfield names separated with dot.
Example:
```
fields: ["a.b.c"]
# event before processing
{
"a": {
"b": {
"c": 100,
"d": "some"
}
}
}
# event after processing
{
"a": {
"b": {
"d": "some" # "c" removed
}
}
}
```

If field name contains dots use backslash for escaping.
Example:
```
fields:
- exception\.type
# event before processing
{
"message": "Exception occurred",
"exception.type": "SomeType"
}
# event after processing
{
"message": "Exception occurred" # "exception.type" removed
}
```

[More details...](plugin/action/remove_fields/README.md)
## rename
Expand Down
42 changes: 42 additions & 0 deletions plugin/action/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,48 @@ It parses string from the event field using re2 expression with named subgroups
[More details...](plugin/action/parse_re2/README.md)
## remove_fields
It removes the list of the event fields and keeps others.
Nested fields supported: list subfield names separated with dot.
Example:
```
fields: ["a.b.c"]
# event before processing
{
"a": {
"b": {
"c": 100,
"d": "some"
}
}
}
# event after processing
{
"a": {
"b": {
"d": "some" # "c" removed
}
}
}
```

If field name contains dots use backslash for escaping.
Example:
```
fields:
- exception\.type
# event before processing
{
"message": "Exception occurred",
"exception.type": "SomeType"
}
# event after processing
{
"message": "Exception occurred" # "exception.type" removed
}
```

[More details...](plugin/action/remove_fields/README.md)
## rename
Expand Down
10 changes: 5 additions & 5 deletions plugin/action/remove_fields/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Remove fields plugin
It removes the list of the event fields and keeps others.

### Config params
**`fields`** *`[]string`*

The list of the fields to remove.
Nested fields supported: list subfield names separated with dot.
Example:
```
Expand Down Expand Up @@ -48,6 +43,11 @@ fields:
}
```

### Config params
**`fields`** *`[]string`*

The list of the fields to remove.

<br>


Expand Down
91 changes: 48 additions & 43 deletions plugin/action/remove_fields/remove_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,48 @@ import (

/*{ introduction
It removes the list of the event fields and keeps others.
Nested fields supported: list subfield names separated with dot.
Example:
```
fields: ["a.b.c"]
# event before processing
{
"a": {
"b": {
"c": 100,
"d": "some"
}
}
}
# event after processing
{
"a": {
"b": {
"d": "some" # "c" removed
}
}
}
```
If field name contains dots use backslash for escaping.
Example:
```
fields:
- exception\.type
# event before processing
{
"message": "Exception occurred",
"exception.type": "SomeType"
}
# event after processing
{
"message": "Exception occurred" # "exception.type" removed
}
```
}*/

type Plugin struct {
Expand All @@ -25,48 +67,6 @@ type Config struct {
// > @3@4@5@6
// >
// > The list of the fields to remove.
// > Nested fields supported: list subfield names separated with dot.
// > Example:
// > ```
// > fields: ["a.b.c"]
// >
// > # event before processing
// > {
// > "a": {
// > "b": {
// > "c": 100,
// > "d": "some"
// > }
// > }
// > }
// >
// > # event after processing
// > {
// > "a": {
// > "b": {
// > "d": "some" # "c" removed
// > }
// > }
// > }
// > ```
// >
// > If field name contains dots use backslash for escaping.
// > Example:
// > ```
// > fields:
// > - exception\.type
// >
// > # event before processing
// > {
// > "message": "Exception occurred",
// > "exception.type": "SomeType"
// > }
// >
// > # event after processing
// > {
// > "message": "Exception occurred" # "exception.type" removed
// > }
// > ```
Fields []string `json:"fields"` // *
}

Expand Down Expand Up @@ -96,7 +96,8 @@ func (p *Plugin) Start(config pipeline.AnyConfig, _ *pipeline.ActionPluginParams

for i, f1 := range fields {
if f1 == "" {
logger.Fatal("empty field found")
logger.Warn("empty field found")
continue
}

ok := true
Expand All @@ -112,6 +113,10 @@ func (p *Plugin) Start(config pipeline.AnyConfig, _ *pipeline.ActionPluginParams
p.fieldPaths = append(p.fieldPaths, cfg.ParseFieldSelector(f1))
}
}

if len(p.fieldPaths) == 0 {
logger.Warn("no fields will be removed")
}
}

func (p *Plugin) Stop() {
Expand Down

0 comments on commit 9a9ef66

Please sign in to comment.