childe / gohangout

使用 golang 模仿的 Logstash。用于消费 Kafka 数据,处理后写入 ES、Clickhouse 等。
MIT License
1.03k stars 238 forks source link

fieldA = fieldB == null ? fieldC : fieldB 语义怎么支持 #144

Closed MaxWk closed 3 years ago

childe commented 3 years ago
inputs:
    - Stdin:
        codec: json

filters:
    - Add:
        if:
            - 'Exist(a)'
        fields:
            c: $.a
    - Add:
        if:
            - '!Exist(a)'
        fields:
            c: $.b

outputs:
    - Stdout: {}
% cat a.txt| gohangout --config gohangout.yml -exit-when-nil
gohangout version 1.7.5
{"@timestamp":"2021-07-14T17:17:32.098875+08:00","a":10,"c":10}
{"@timestamp":"2021-07-14T17:17:32.101337+08:00","b":20,"c":20}
{"@timestamp":"2021-07-14T17:17:32.101399+08:00","a":10,"b":20,"c":10}
{"@timestamp":"2021-07-14T17:17:32.101423+08:00","b":20,"c":20,"x":10}

% cat a.txt
{"a":10}
{"b":20}
{"a":10,"b":20}
{"x":10,"b":20}