fluent-bit: convert kmsg pri field from char to string

In order to support filtering based on serverity and facility in
logmngr config, we need to be able to configure regex on the
priority field, but kmsg input plugin sends the priority field as
char, on which regex does not work. We also cannot use the type
converter filter which is present in fluent bit, because it does
not support the source data type to be char. Therefore, we change
priority from a char to a string field.
This commit is contained in:
Mohd Husaam Mehdi 2025-08-29 12:48:45 +05:30 committed by Husaam Mehdi
parent 43a0dfc863
commit fea302bd43

View file

@ -0,0 +1,20 @@
diff --git a/plugins/in_kmsg/in_kmsg.c b/plugins/in_kmsg/in_kmsg.c
index cd5c4cd17..04bbe2b2e 100644
--- a/plugins/in_kmsg/in_kmsg.c
+++ b/plugins/in_kmsg/in_kmsg.c
@@ -182,11 +182,14 @@ static inline int process_line(const char *line,
&ts);
}
+ char priority_str[4] = {0}; /* enough for "255" + NUL */
+ snprintf(priority_str, sizeof(priority_str), "%u", (unsigned char) priority);
+
if (ret == FLB_EVENT_ENCODER_SUCCESS) {
ret = flb_log_event_encoder_append_body_values(
&ctx->log_encoder,
FLB_LOG_EVENT_CSTRING_VALUE("priority"),
- FLB_LOG_EVENT_CHAR_VALUE(priority),
+ FLB_LOG_EVENT_STRING_VALUE(priority_str, strlen(priority_str)),
FLB_LOG_EVENT_CSTRING_VALUE("sequence"),
FLB_LOG_EVENT_UINT64_VALUE(sequence),