summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/plugins/filter_modify/modify.h
blob: 92c590e013b0a62005558b7fcb92b9a65c66f48a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*  Fluent Bit
 *  ==========
 *  Copyright (C) 2015-2022 The Fluent Bit Authors
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

#ifndef FLB_FILTER_MODIFY_H
#define FLB_FILTER_MODIFY_H

#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_filter.h>
#include <fluent-bit/flb_record_accessor.h>
#include <fluent-bit/flb_sds.h>

enum FLB_FILTER_MODIFY_RULETYPE {
  RENAME,
  HARD_RENAME,
  ADD,
  SET,
  REMOVE,
  REMOVE_WILDCARD,
  REMOVE_REGEX,
  COPY,
  HARD_COPY,
  MOVE_TO_START,
  MOVE_TO_END
};

enum FLB_FILTER_MODIFY_CONDITIONTYPE {
  KEY_EXISTS,
  KEY_DOES_NOT_EXIST,
  A_KEY_MATCHES,
  NO_KEY_MATCHES,
  KEY_VALUE_EQUALS,
  KEY_VALUE_DOES_NOT_EQUAL,
  KEY_VALUE_MATCHES,
  KEY_VALUE_DOES_NOT_MATCH,
  MATCHING_KEYS_HAVE_MATCHING_VALUES,
  MATCHING_KEYS_DO_NOT_HAVE_MATCHING_VALUES
};

struct filter_modify_ctx
{
    int rules_cnt;
    struct mk_list rules;
    int conditions_cnt;
    struct mk_list conditions;
    struct flb_filter_instance *ins;
};

struct modify_rule
{
    enum FLB_FILTER_MODIFY_RULETYPE ruletype;
    int key_len;
    int val_len;
    char *key;
    char *val;
    bool key_is_regex;
    bool val_is_regex;
    struct flb_regex *key_regex;
    struct flb_regex *val_regex;
    char *raw_k;
    char *raw_v;
    struct mk_list _head;
};

struct modify_condition
{
    enum FLB_FILTER_MODIFY_CONDITIONTYPE conditiontype;
    int a_len;
    int b_len;
    flb_sds_t a;
    char *b;
    bool a_is_regex;
    bool b_is_regex;
    struct flb_regex *a_regex;
    struct flb_regex *b_regex;
    struct flb_record_accessor *ra_a;
    char *raw_k;
    char *raw_v;
    struct mk_list _head;
};
#endif