Compare commits

...

1 Commits

Author SHA1 Message Date
Mohd Husaam Mehdi
fea302bd43 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.
2025-08-29 12:30:04 +00:00

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),