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

added fluentd-record-modifier plugin #349

Merged
merged 3 commits into from
Feb 7, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,56 @@ spec:
type: object
type: array
type: object
record_modifier:
properties:
char_encoding:
description: Fluentd including some plugins treats logs as
a BINARY by default to forward. To overide that, use a target
encoding or a from:to encoding here.
type: string
prepare_value:
description: Prepare values for filtering in configure phase.
Prepared values can be used in <record>. You can write any
ruby code.
type: string
records:
description: 'Add records docs at: https://github.com/repeatedly/fluent-plugin-record-modifier
Records are represented as maps: `key: value`'
items:
additionalProperties:
type: string
description: Parameters inside record directives are considered
to be new key-value pairs
type: object
type: array
remove_keys:
description: A comma-delimited list of keys to delete
type: string
replaces:
description: Replace specific value for keys
items:
description: Specify replace rule. This directive contains
three parameters.
properties:
expression:
description: Regular expression
type: string
key:
description: Key to search for
type: string
replace:
description: Value to replace with
type: string
required:
- expression
- key
- replace
type: object
type: array
whitelist_keys:
description: This is exclusive with remove_keys
type: string
type: object
record_transformer:
properties:
auto_typecast:
Expand Down
50 changes: 50 additions & 0 deletions charts/logging-operator/crds/logging.banzaicloud.io_flows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,56 @@ spec:
type: object
type: array
type: object
record_modifier:
properties:
char_encoding:
description: Fluentd including some plugins treats logs as
a BINARY by default to forward. To overide that, use a target
encoding or a from:to encoding here.
type: string
prepare_value:
description: Prepare values for filtering in configure phase.
Prepared values can be used in <record>. You can write any
ruby code.
type: string
records:
description: 'Add records docs at: https://github.com/repeatedly/fluent-plugin-record-modifier
Records are represented as maps: `key: value`'
items:
additionalProperties:
type: string
description: Parameters inside record directives are considered
to be new key-value pairs
type: object
type: array
remove_keys:
description: A comma-delimited list of keys to delete
type: string
replaces:
description: Replace specific value for keys
items:
description: Specify replace rule. This directive contains
three parameters.
properties:
expression:
description: Regular expression
type: string
key:
description: Key to search for
type: string
replace:
description: Value to replace with
type: string
required:
- expression
- key
- replace
type: object
type: array
whitelist_keys:
description: This is exclusive with remove_keys
type: string
type: object
record_transformer:
properties:
auto_typecast:
Expand Down
50 changes: 50 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_clusterflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,56 @@ spec:
type: object
type: array
type: object
record_modifier:
properties:
char_encoding:
description: Fluentd including some plugins treats logs as
a BINARY by default to forward. To overide that, use a target
encoding or a from:to encoding here.
type: string
prepare_value:
description: Prepare values for filtering in configure phase.
Prepared values can be used in <record>. You can write any
ruby code.
type: string
records:
description: 'Add records docs at: https://github.com/repeatedly/fluent-plugin-record-modifier
Records are represented as maps: `key: value`'
items:
additionalProperties:
type: string
description: Parameters inside record directives are considered
to be new key-value pairs
type: object
type: array
remove_keys:
description: A comma-delimited list of keys to delete
type: string
replaces:
description: Replace specific value for keys
items:
description: Specify replace rule. This directive contains
three parameters.
properties:
expression:
description: Regular expression
type: string
key:
description: Key to search for
type: string
replace:
description: Value to replace with
type: string
required:
- expression
- key
- replace
type: object
type: array
whitelist_keys:
description: This is exclusive with remove_keys
type: string
type: object
record_transformer:
properties:
auto_typecast:
Expand Down
50 changes: 50 additions & 0 deletions config/crd/bases/logging.banzaicloud.io_flows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,56 @@ spec:
type: object
type: array
type: object
record_modifier:
properties:
char_encoding:
description: Fluentd including some plugins treats logs as
a BINARY by default to forward. To overide that, use a target
encoding or a from:to encoding here.
type: string
prepare_value:
description: Prepare values for filtering in configure phase.
Prepared values can be used in <record>. You can write any
ruby code.
type: string
records:
description: 'Add records docs at: https://github.com/repeatedly/fluent-plugin-record-modifier
Records are represented as maps: `key: value`'
items:
additionalProperties:
type: string
description: Parameters inside record directives are considered
to be new key-value pairs
type: object
type: array
remove_keys:
description: A comma-delimited list of keys to delete
type: string
replaces:
description: Replace specific value for keys
items:
description: Specify replace rule. This directive contains
three parameters.
properties:
expression:
description: Regular expression
type: string
key:
description: Key to search for
type: string
replace:
description: Value to replace with
type: string
required:
- expression
- key
- replace
type: object
type: array
whitelist_keys:
description: This is exclusive with remove_keys
type: string
type: object
record_transformer:
properties:
auto_typecast:
Expand Down
1 change: 1 addition & 0 deletions docs/crds/v1beta1/flow_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
| tag_normaliser | *filter.TagNormaliser | No | - | |
| dedot | *filter.DedotFilterConfig | No | - | |
| record_transformer | *filter.RecordTransformer | No | - | |
| record_modifier | *filter.RecordModifier | No | - | |
| geoip | *filter.GeoIP | No | - | |
| concat | *filter.Concat | No | - | |
| detectExceptions | *filter.DetectExceptions | No | - | |
Expand Down
1 change: 1 addition & 0 deletions docs/plugins/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ For more information please click on the plugin name
| **[Grep](filters/grep.md)** | filters | Grep events by the values | GA | [more info](https://docs.fluentd.org/filter/grep) |
| **[Parser](filters/parser.md)** | filters | Parses" string field in event records and mutates its | GA | [more info](https://docs.fluentd.org/filter/parser) |
| **[Prometheus](filters/prometheus.md)** | filters | Prometheus Filter Plugin to count Incoming Records | GA | [more info](https://github.com/fluent/fluent-plugin-prometheus#prometheus-outputfilter-plugin) |
| **[Record Modifier](filters/record_modifier.md)** | filters | Modify each event record. | GA | [more info](https://github.com/repeatedly/fluent-plugin-record-modifier) |
| **[Record Transformer](filters/record_transformer.md)** | filters | Mutates/transforms incoming event streams. | GA | [more info](https://docs.fluentd.org/filter/record_transformer) |
| **[Stdout](filters/stdout.md)** | filters | Prints events to stdout | GA | [more info](https://docs.fluentd.org/filter/stdout) |
| **[Tag Normaliser](filters/tagnormaliser.md)** | filters | Re-tag based on log metadata | GA | [more info](https://github.com/banzaicloud/fluent-plugin-tag-normaliser) |
Expand Down
50 changes: 50 additions & 0 deletions docs/plugins/filters/record_modifier.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# [Record Modifier](https://github.com/repeatedly/fluent-plugin-record-modifier)
## Overview
Modify each event record.

## Configuration
### RecordModifier
| Variable Name | Type | Required | Default | Description |
|---|---|---|---|---|
| prepare_value | string | No | - | Prepare values for filtering in configure phase. Prepared values can be used in <record>. You can write any ruby code.<br> |
| char_encoding | string | No | - | Fluentd including some plugins treats logs as a BINARY by default to forward. To overide that, use a target encoding or a from:to encoding here.<br> |
| remove_keys | string | No | - | A comma-delimited list of keys to delete<br> |
| whitelist_keys | string | No | - | This is exclusive with remove_keys<br> |
| replaces | []Replace | No | - | Replace specific value for keys<br> |
| records | []Record | No | - | Add records docs at: https://github.com/repeatedly/fluent-plugin-record-modifier<br>Records are represented as maps: `key: value`<br> |
#### Example `Record Modifier` filter configurations
```yaml
apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
name: demo-flow
spec:
filters:
- record_modifier:
records:
- foo: "bar"
selectors: {}
outputRefs:
- demo-output
```

#### Fluentd Config Result
```yaml
<filter **>
@type record_modifier
@id test_record_modifier
<record>
foo bar
</record>
</filter>
```

---
### [Replace Directive](https://github.com/repeatedly/fluent-plugin-record-modifier#replace_keys_value)
#### Specify replace rule. This directive contains three parameters.

| Variable Name | Type | Required | Default | Description |
|---|---|---|---|---|
| key | string | Yes | - | Key to search for<br> |
| expression | string | Yes | - | Regular expression<br> |
| replace | string | Yes | - | Value to replace with<br> |
1 change: 1 addition & 0 deletions fluentd-image/v1.7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ RUN apk update \
fluent-plugin-parser-logfmt \
fluent-plugin-detect-exceptions \
fluent-plugin-multi-format-parser \
fluent-plugin-record-modifier \
&& gem specific_install -l https://github.com/banzaicloud/fluent-plugin-cloudwatch-logs/releases/download/v0.7.6/fluent-plugin-cloudwatch-logs-0.7.6.gem \
&& gem specific_install -l https://github.com/banzaicloud/fluent-plugin-gcs.git \
&& apk del .build-deps $buildDeps \
Expand Down
1 change: 1 addition & 0 deletions pkg/sdk/api/v1beta1/flow_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Filter struct {
TagNormaliser *filter.TagNormaliser `json:"tag_normaliser,omitempty"`
Dedot *filter.DedotFilterConfig `json:"dedot,omitempty"`
RecordTransformer *filter.RecordTransformer `json:"record_transformer,omitempty"`
RecordModifier *filter.RecordModifier `json:"record_modifier,omitempty"`
GeoIP *filter.GeoIP `json:"geoip,omitempty"`
Concat *filter.Concat `json:"concat,omitempty"`
DetectExceptions *filter.DetectExceptions `json:"detectExceptions,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/sdk/api/v1beta1/zz_generated.deepcopy.go

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

Loading