Skip to content

Commit

Permalink
filter: Handle each of types of events if capabilities can handle them
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Hatake <[email protected]>
  • Loading branch information
cosmo0920 committed Jan 29, 2024
1 parent fdf8795 commit 15c9aba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/fluent-bit/flb_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define FLB_FILTER_H

#include <fluent-bit/flb_info.h>
#include <fluent-bit/flb_input.h>

#ifdef FLB_HAVE_REGEX
#include <fluent-bit/flb_regex.h>
Expand Down
23 changes: 23 additions & 0 deletions src/flb_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ static inline int prop_key_check(const char *key, const char *kv, int k_len)
return -1;
}

static inline int flb_filter_match_type(int in_event_type,
struct flb_filter_instance *f_ins)
{
if (in_event_type == FLB_INPUT_LOGS &&
!(f_ins->event_type & FLB_FILTER_LOGS)) {
return FLB_FALSE;
}
else if (in_event_type == FLB_INPUT_METRICS &&
!(f_ins->event_type & FLB_FILTER_METRICS)) {
return FLB_FALSE;
}
else if (in_event_type == FLB_INPUT_TRACES &&
!(f_ins->event_type & FLB_FILTER_TRACES)) {
return FLB_FALSE;
}

return FLB_TRUE;
}

void flb_filter_do(struct flb_input_chunk *ic,
const void *data, size_t bytes,
void **out_data, size_t *out_bytes,
Expand Down Expand Up @@ -138,6 +157,10 @@ void flb_filter_do(struct flb_input_chunk *ic,
continue;
}

if (!flb_filter_match_type(event_type, f_ins)) {
continue;
}

if (flb_router_match(ntag, tag_len, f_ins->match
#ifdef FLB_HAVE_REGEX
, f_ins->match_regex
Expand Down

0 comments on commit 15c9aba

Please sign in to comment.