Hi! can i get help here with clusterfilters / clus...
# fluent-operator
o
Hi! can i get help here with clusterfilters / clusterparsers?
j
What is your question?
🙌 1
o
I have a fluent-bit daemonset with fluentd, which forwards to opensearch, I try to parse a "java" format log log with clusterparser+clusterfilter, i use a regex parser, which breaks the log into fields, one if the fields is "logtime", which holds a timestamp.
Copy code
apiVersion: <http://fluentbit.fluent.io/v1alpha2|fluentbit.fluent.io/v1alpha2>
kind: ClusterParser
metadata:
  name: regex-for-clusterfilter-nbo-job
  labels:
    <http://fluentbit.fluent.io/component|fluentbit.fluent.io/component>: logging
    <http://fluentbit.fluent.io/enabled|fluentbit.fluent.io/enabled>: 'true'
spec:
  regex:
    regex: '^(?<containertime>\S+)\s+(?<stdtype>(stdout|stderr))\s+(F|P)\s+(?<logtime>\d{4}-\d{1,2}-\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2}\.\d*)\s+(?<level>.+)\s*---\s*\[\s*(?<thread>\S+)\]\s*(?<message>[.\s\S]+)' 
    timeKey: logtime
    timeFormat: '%Y-%m-%d %H:%M:%S.%N'
    timeKeep: false
I can't get the "logtime" key to become the timestamp, i do see the field within opensearch - it should be removed if the parser worked
i've made sure that the timeformat is correct
here is the clusterfilter:
Copy code
kind: ClusterFilter
metadata:
  name: nbo-job
  labels:
    <http://fluentbit.fluent.io/component|fluentbit.fluent.io/component>: logging
    <http://fluentbit.fluent.io/enabled|fluentbit.fluent.io/enabled>: 'true'
spec:
  ordinal: 999
  match: nbo.job.*
  filters:
    - parser:
        keyName: log
        parser: regex-for-clusterfilter-nbo-job
        reserveData: true
c
to verify your parser work or not, you can add stdout filter or output.
o
I do have an output, my log is sent parsed as expected, but "logtime" seem to not be parsed, and stays as a field within the record.
I have a similar setup for fluentd [ i'm migrating from a fluentd daemonset into the fluent-operator ]:
Copy code
<source>
      @type tail
      read_lines_limit 250
      path_key tailed_path
      path ...
      tag ...
      multiline_flush_interval 30s
      <parse>
        @type multiline
        format_firstline /^\S+\s(stdout|stderr)\s(F|P)\s\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}:\d{1,2}/
        format1 /^(?<containertime>\S+)\s+(?<stdtype>(stdout|stderr))\s+(F|P)\s+(?<logtime>\d{4}-\d{1,2}-\d{1,2}\s+\d{1,2}:\d{1,2}:\d{1,2}\.\d*)\s+(?<level>.+)\s*---\s*\[\s*(?<thread>\S+)\]\s*(?<message>[.\s\S]+)/
        time_key logtime
        time_format %Y-%m-%d %H:%M:%S.%N
      </parse>
    </source>
this works, and I try to re-create the same behavior for fluentbit