Skip to content

help request: Can anyone explain how the clusterfilter works on Fluentd with tags? #1457

@Crazyigor1987

Description

@Crazyigor1987

Describe the issue

Hi!

Can anyone explain how the clusterfilter works on Fluentd with tags?

I have a fluentbit -> fluentd forward setup. The logs in fluentbit are correctly tagged and passed to fluentd. In my case, i want to create a clusterfilter on fluentd side, which matches the tag and performs the filter in ordered manner. I quite don't understand, why the tag is only set per filter. I expect that all filters are performed matched per one tag.

My setup looks like this:

apiVersion: fluentd.fluent.io/v1alpha1
kind: ClusterFilter
metadata:
  name: 001-istio-proxy-parser
  labels:
    fluentd.default.filter: "true"
spec:
  filters:
    - tag: "istio-proxy.*"
    - parser:
        keyName: log
        parse:
          type: json
        reserveData: true 
        removeKeyNameField: false
        injectKeyPrefix: "parsed."
        emitInvalidRecordToError: false
    - recordTransformer:
        enableRuby: true
        records:
          - key: istio
            value: '${record["container_name"] == "istio-proxy" && record["parsed"] ? record["parsed"] : nil}'
          - key: log
            value: '${record["container_name"] == "istio-proxy" && record["parsed"] ? nil : record["log"]}'
        removeKeys: "parsed"

The result looks like this:
Got <filter "istio-proxy.*>" and the following filters "<filter **>".

<source>
  @type  forward
  bind  0.0.0.0
  port  24224
</source>
<match **>
  @id  main
  @type  label_router
  <route>
    @label  @db681e4cb763ca5b7cdbf9ab76f67bbe
    <match>
    </match>
  </route>
</match>
<label @db681e4cb763ca5b7cdbf9ab76f67bbe>
  <filter istio-proxy.*>
    @id  ClusterFluentdConfig-cluster-fluentd-config::cluster::clusterfilter::001-istio-proxy-parser-0
  </filter>
  <filter **>
    @id  ClusterFluentdConfig-cluster-fluentd-config::cluster::clusterfilter::001-istio-proxy-parser-1
    @type  parser
    emit_invalid_record_to_error  false
    inject_key_prefix  parsed.
    key_name  log
    remove_key_name_field  false
    reserve_data  true
    <parse>
      @type  json
    </parse>
  </filter>
  <filter **>
    @id  ClusterFluentdConfig-cluster-fluentd-config::cluster::clusterfilter::001-istio-proxy-parser-2
    @type  record_transformer
    enable_ruby  true
    remove_keys  parsed
    <record>
      istio  ${record["container_name"] == "istio-proxy" && record["parsed"] ? record["parsed"] : nil}
      log  ${record["container_name"] == "istio-proxy" && record["parsed"] ? nil : record["log"]}
    </record>
  </filter>
  <match **>
    @id  ClusterFluentdConfig-cluster-fluentd-config::cluster::clusteroutput::fluentd-output-stdout-0
    @type  stdout
  </match>
</label>

How did you install fluent operator?

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions