ozontech / ozontech/file.d

[draft] Feature: match_fields v2

Open
#325 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
504
Forks
263
Avg merge
4d 2h
Merged PRs (30d)
5

Description

match_fields allows us to selectively apply Actions. But the current implementation of match_fields does not allow us to do things like empty string checking, object type checking, etc.

We have two ways: write own query language or describe it in config.

The new API will look like this:

pipelines:
  k8s:
    actions:
      - type: 'modify'
        service: 'unknown'
        do_if:
          - cond: 'equal'
            field: 'service'
            value: null
            or: # TODO: same is a new condition?
              - cond: 'equal'
                # field: 'service' -- 'field' was inherited from the parent
                value: ''

      - type: 'modify'
        message: 'Invalid message'
        do_if:
          - cond: 'type_equal'
            field: 'message'
            invert: true
            value: 'string'

      - type: 'modify'
        level: 'unknown'
        do_if:
          - cond: 'equal'
            field: 'level'
            value: null
          - cond: 'equal'
            field: 'level'
            value: ''

      - type: 'throttle'
        do_if:
          - cond: 'equal'
            field: 'service'
            value: 'unknown'
            and:
              - cond: 'prefix'
                invert: true
                field: 'level'
                value: 'err'
              - cond: 'in'
                invert: true
                field: 'level'
                value: ['panic', null, 'warn']

      - type: 'modify'
        important_event: true
        do_if:
          cond: 'equal'
          invert: true
          field: 'service'
          value: 'unknown'
          and:
            cond: 'in'
            field: 'level'
            value: [ 'error', 'warn' ]

It looks wordy than creating own language, but greatly simplifies the implementation.
I’ll explore alternative solutions.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing match_fields implementation and compare it with the proposed do_if YAML examples in this issue. Resolve whether a query language or configuration-based API is wanted, then define supported conditions and nesting before implementation; the issue currently provides no tests, files, or completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.