Hi everyone, I'm facing a small issue. I have some...
# fluent-bit
l
Hi everyone, I'm facing a small issue. I have some logs coming from Traefik into a file. I want to parse the message, check the Origin Status, and apply the following rules: 1. If Origin Status < 400, then insert field level = info 2. If Origin Status >= 400 and Origin Status < 500, then insert field level = warn 3. If Origin Status >= 500, then insert field level = error Here is my configuration, but whatever I do, I always get level = info:
Copy code
pipeline:
  inputs:
    - name: tail
      path: /var/log/traefik/access.log
      parser: traefik
      processors:
        logs:
          - name: content_modifier
            action: insert
            key: level
            value: new
            condition:
              op: lt
              rules:
                - field: "$OriginStatus"
                  op: lt
                  value: 400
          - name: content_modifier
            action: insert
            key: level
            value: warn
            condition:
              op: and
              rules:
                - field: "$OriginStatus"
                  op: gte
                  value: 400
                - field: "$OriginStatus"
                  op: lt
                  value: 500
          - name: content_modifier
            action: insert
            key: level
            value: error
            condition:
              op: gte
              rules:
                - field: "$OriginStatus"
                  op: gte
                  value: 500
  outputs:
    - name: stdout
      match: "*"
      format: "json"
p
Is the field actually a number?
I would set up a dummy input to drive example data through your processors and see what is going on that way
l
it is a number
p
I would do a dummy input where you explicitly set the value with the processors and check what is going on. It should work so I wonder if something weird is happening in the data. If you can simplify it down to a reproducer as well then super helpful for raising an issue or asking without needing the actual log file every time.
l
Copy code
pipeline:
  inputs:
    - name: dummy
      dummy: '{"OriginStatus":401}'
      processors:
        logs:
          - name: content_modifier
            action: insert
            key: level
            value: new
            condition:
              op: and
              rules:
                - field: "$OriginStatus"
                  op: lt
                  value: 400
          - name: content_modifier
            action: insert
            key: level
            value: warn
            condition:
              op: and
              rules:
                - field: "$OriginStatus"
                  op: gte
                  value: 400
                - field: "$OriginStatus"
                  op: lt
                  value: 500
          - name: content_modifier
            action: insert
            key: level
            value: error
            condition:
              op: and
              rules:
                - field: "$OriginStatus"
                  op: gte
                  value: 500
  outputs:
    - name: stdout
      match: "*"
      format: "json"
defintely not working, no idea why