fluent / fluent-operator

Operate Fluent Bit and Fluentd in the Kubernetes way - Previously known as FluentBit Operator
Apache License 2.0
587 stars 250 forks source link

Render ConfigMap only if key is not empty string #1299

Closed dex4er closed 3 months ago

dex4er commented 3 months ago

What this PR does / why we need it:

It should allow to use inline code for Lua scripts

Which issue(s) this PR fixes:

Fixes #1287

Does this PR introduced a user-facing change?

No
dex4er commented 3 months ago

Tested with image: public.ecr.aws/dex4er/fluent-operator:pr-1298-1299

filter:

apiVersion: fluentbit.fluent.io/v1alpha2
kind: ClusterFilter
metadata:
  name: append-tag
  labels:
    fluentbit.fluent.io/enabled: "true"
    fluentbit.fluent.io/mode: fluentbit-only
spec:
  match: "*"
  filters:
    - lua:
        call: append_tag
        code: |
          function append_tag(tag, timestamp, record)
            new_record = record
            new_record["meta_type"] = tag
            return 2, timestamp, new_record
          end

output:

[Filter]
    Name    lua
    Match    *
    code    function append_tag(tag, timestamp, record) new_record = record; new_record["meta_type"] = tag; return 2, timestamp, new_record; end 
    call    append_tag