-
Notifications
You must be signed in to change notification settings - Fork 1.8k
router: add conditional support for Logs #11055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
33cdbbe
ac42f67
839a397
3e147e1
a4ace4e
947c874
840e2ba
10058f2
eb798a7
e662be2
38b010a
966387c
b923d4a
4163712
55f9e0e
2c2a5cf
20eeb44
49e41fe
b727628
28946e8
4a82d5d
cb67d1c
c7949cc
ac76b20
a7e4c92
8183d93
fde4e06
8d2105f
cb2ce79
90bfb20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,6 +20,16 @@ | |||||||||||
| #include <fluent-bit/flb_mem.h> | ||||||||||||
| #include <fluent-bit/flb_log.h> | ||||||||||||
| #include <fluent-bit/flb_router.h> | ||||||||||||
| #include <fluent-bit/flb_conditionals.h> | ||||||||||||
| #include <fluent-bit/flb_log_event_decoder.h> | ||||||||||||
| #include <fluent-bit/flb_mp.h> | ||||||||||||
| #include <fluent-bit/flb_mp_chunk.h> | ||||||||||||
|
|
||||||||||||
| #define FLB_ROUTE_CONDITION_COMPILED_SUCCESS 1 | ||||||||||||
| #define FLB_ROUTE_CONDITION_COMPILED_FAILURE -1 | ||||||||||||
|
|
||||||||||||
| static struct flb_condition *route_condition_get_compiled(struct flb_route_condition *condition); | ||||||||||||
| static void route_condition_record_destroy(struct flb_mp_chunk_record *record); | ||||||||||||
|
|
||||||||||||
| uint32_t flb_router_signal_from_chunk(struct flb_event_chunk *chunk) | ||||||||||||
| { | ||||||||||||
|
|
@@ -44,18 +54,68 @@ uint32_t flb_router_signal_from_chunk(struct flb_event_chunk *chunk) | |||||||||||
| int flb_condition_eval_logs(struct flb_event_chunk *chunk, | ||||||||||||
| struct flb_route *route) | ||||||||||||
| { | ||||||||||||
| (void) chunk; | ||||||||||||
| (void) route; | ||||||||||||
| int ret; | ||||||||||||
| int result = FLB_FALSE; | ||||||||||||
| struct flb_route_condition *condition; | ||||||||||||
| struct flb_condition *compiled; | ||||||||||||
| struct flb_log_event_decoder decoder; | ||||||||||||
| struct flb_log_event event; | ||||||||||||
| struct flb_mp_chunk_record record; | ||||||||||||
|
|
||||||||||||
| /* | ||||||||||||
| * The full condition evaluation engine requires field resolvers that map | ||||||||||||
| * record accessors to the different telemetry payload shapes. The wiring | ||||||||||||
| * of those resolvers is part of a bigger effort and will be implemented in | ||||||||||||
| * follow-up changes. For the time being we simply report that the | ||||||||||||
| * condition failed so that the runtime can rely on explicit default | ||||||||||||
| * routes. | ||||||||||||
| */ | ||||||||||||
| return FLB_FALSE; | ||||||||||||
| if (!chunk || !route || !route->condition) { | ||||||||||||
| return FLB_FALSE; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (!chunk->data || chunk->size == 0) { | ||||||||||||
| return FLB_FALSE; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| condition = route->condition; | ||||||||||||
|
|
||||||||||||
| compiled = route_condition_get_compiled(condition); | ||||||||||||
| if (!compiled) { | ||||||||||||
| return FLB_FALSE; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| ret = flb_log_event_decoder_init(&decoder, chunk->data, chunk->size); | ||||||||||||
| if (ret != FLB_EVENT_DECODER_SUCCESS) { | ||||||||||||
| return FLB_FALSE; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
| flb_log_event_decoder_read_groups(&decoder, FLB_TRUE); | ||||||||||||
|
|
||||||||||||
|
||||||||||||
| flb_log_event_decoder_read_groups(&decoder, FLB_TRUE); | |
| if (flb_log_event_decoder_read_groups(&decoder, FLB_FALSE) != 0) { | |
| flb_log_event_decoder_destroy(&decoder); | |
| return FLB_FALSE; | |
| } |
🤖 Prompt for AI Agents
In src/flb_router_condition.c around lines 85-86, the call to
flb_log_event_decoder_read_groups(&decoder, FLB_TRUE) causes group open/close
meta records to be surfaced and wrongly evaluated; change this to disable
reading group meta records (use FLB_FALSE / remove the read_groups enable) so
the decoder only propagates group context to normal records, and check the
function's return value for errors—handle a non-success return by logging an
error and returning/propagating failure appropriately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add missing standard headers for strcasecmp/strtod/errno
This file uses strcasecmp, strtod and errno but doesn’t include their headers. Some platforms won’t get these via transitive includes, causing build failures.
Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents