From a5ca7344e9712eb8ca143fd7cd482c0f3fae5fc6 Mon Sep 17 00:00:00 2001 From: Mohd Husaam Mehdi Date: Tue, 30 Dec 2025 16:25:35 +0530 Subject: [PATCH] fluent-bit: align with upstream openwrt fluent-bit package --- fluent-bit/Makefile | 79 ++++++++++++-------------- fluent-bit/patches/0020-fix_kmsg.patch | 43 +++++++------- 2 files changed, 55 insertions(+), 67 deletions(-) diff --git a/fluent-bit/Makefile b/fluent-bit/Makefile index 9d5fe01bd..6990f43a6 100644 --- a/fluent-bit/Makefile +++ b/fluent-bit/Makefile @@ -1,21 +1,13 @@ -# -# Copyright (C) 2024-2025 IOPSYS -# - include $(TOPDIR)/rules.mk PKG_NAME:=fluent-bit -PKG_VERSION:=4.0.4 -PKG_RELEASE:=$(AUTORELEASE) +PKG_VERSION:=4.2.0 +PKG_RELEASE:=1 -LOCAL_DEV:=0 -ifneq ($(LOCAL_DEV),1) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://github.com/fluent/fluent-bit.git PKG_SOURCE_VERSION=v$(PKG_VERSION) -PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.zst -PKG_MIRROR_HASH:=skip -endif +PKG_MIRROR_HASH:=cad2d94cf7a720a3910c781f80187e2c399aa8acbfa1046aa7445a4d1495fafd PKG_LICENSE:=Apache-2.0 PKG_LICENSE_FILES:=LICENSE @@ -24,52 +16,55 @@ include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk define Package/fluent-bit - CATEGORY:=Utilities - DEPENDS:= +libyaml +libopenssl +libcurl +libatomic +musl-fts +flex +bison +libstdcpp +@OPENSSL_WITH_NPN - TITLE:=Fluent-Bit - URL:=https://fluentbit.io/ + SECTION:=admin + CATEGORY:=Administration + TITLE:=Fast and Lightweight Logs and Metrics processor + URL:=https://fluentbit.io/ + DEPENDS:= +libyaml +libopenssl +libcurl +libstdcpp +libatomic +musl-fts +flex +bison \ + +libsasl2 +@OPENSSL_WITH_NPN endef define Package/fluent-bit/description - Fluent Bit is a super fast, lightweight, and highly scalable logging and metrics processor and forwarder. + Fluent Bit is a super fast, lightweight, and highly scalable logging + and metrics processor and forwarder. endef -ifeq ($(LOCAL_DEV),1) -define Build/Prepare - $(CP) -rf ./fluent-bit/* $(PKG_BUILD_DIR)/ +define Package/fluent-bit/conffiles +/etc/fluent-bit/parsers.conf endef -endif -# General options TARGET_LDFLAGS +=-lfts -latomic CMAKE_OPTIONS+= \ -DFLB_RELEASE=Yes \ - -DFLB_SMALL=No \ -DEXCLUDE_FROM_ALL=true \ - -DFLB_SHARED_LIB=Yes \ - -DFLB_DEBUG=Yes \ - -DFLB_ALL=No \ - -DFLB_JEMALLOC=No \ -DFLB_EXAMPLES=No \ -DFLB_CHUNK_TRACE=No \ -DFLB_BACKTRACE=No \ - -DFLB_KAFKA=No \ -DFLB_WASM=No \ - -DFLB_LUAJIT=Yes + -DFLB_LUAJIT=Yes \ + -DWITH_SASL=No \ + -DWITH_ZLIB=No \ + -DWITH_ZSTD=No + +CMAKE_OPTIONS += \ + -DFLB_SMALL=Yes \ + -DFLB_ALL=No \ + -DFLB_DEBUG=Yes \ + -DFLB_JEMALLOC=No \ + -DFLB_KAFKA=No -# In plugins CMAKE_OPTIONS += \ -DFLB_IN_SYSLOG=Yes \ -DFLB_IN_CPU=Yes \ -DFLB_IN_MEM=Yes \ -DFLB_IN_DISK=Yes \ - -DFLB_IN_EXEC=Yes \ -DFLB_IN_HEAD=Yes \ -DFLB_IN_KMSG=Yes \ -DFLB_IN_TAIL=Yes \ - -DFLB_IN_FORWARD=No \ -DFLB_IN_PROC=No \ + -DFLB_IN_EXEC=No \ + -DFLB_IN_FORWARD=No \ -DFLB_IN_RANDOM=No \ -DFLB_IN_SERIAL=No \ -DFLB_IN_MQTT=No \ @@ -85,7 +80,6 @@ CMAKE_OPTIONS += \ -DFLB_IN_KUBERNETES_EVENTS=No \ -DFLB_IN_KAFKA=No \ -DFLB_IN_LIB=No \ - -DFLB_IN_SYSTEMD=No \ -DFLB_IN_DUMMY=No \ -DFLB_IN_NETIF=No \ -DFLB_IN_COLLECTD=No \ @@ -96,18 +90,18 @@ CMAKE_OPTIONS += \ -DFLB_IN_OPENTELEMETRY=No \ -DFLB_IN_ELASTICSEARCH=No \ -DFLB_IN_CALYPTIA_FLEET=No \ - -DFLB_IN_SPLUNK=No + -DFLB_IN_SPLUNK=No \ -DFLB_IN_HEALTH=No \ -DFLB_IN_WINLOG=No \ -DFLB_IN_WINEVTLOG=No - -# Filter options CMAKE_OPTIONS += \ + -DFLB_FILTER_LUA=Yes \ + -DFLB_FILTER_SYSINFO=Yes \ + -DFLB_FILTER_MODIFY=Yes \ -DFLB_FILTER_AWS=No \ -DFLB_FILTER_ECS=No \ -DFLB_FILTER_KUBERNETES=No \ - -DFLB_FILTER_LUA=Yes \ -DFLB_FILTER_NEST=No \ -DFLB_FILTER_RECORD_MODIFIER=No \ -DFLB_FILTER_THROTTLE=No \ @@ -117,10 +111,8 @@ CMAKE_OPTIONS += \ -DFLB_FILTER_GEOIP2=No \ -DFLB_FILTER_NIGHTFALL=No -# out plugins CMAKE_OPTIONS += \ -DFLB_OUT_EXIT=Yes \ - -DFLB_OUT_FORWARD=Yes \ -DFLB_OUT_HTTP=Yes \ -DFLB_OUT_NATS=Yes \ -DFLB_OUT_TCP=Yes \ @@ -129,6 +121,7 @@ CMAKE_OPTIONS += \ -DFLB_OUT_STDOUT=Yes \ -DFLB_OUT_SYSLOG=Yes \ -DFLB_OUT_NULL=Yes \ + -DFLB_OUT_FORWARD=No \ -DFLB_OUT_PLOT=No \ -DFLB_OUT_AZURE=No \ -DFLB_OUT_AZURE_BLOB=No \ @@ -142,6 +135,7 @@ CMAKE_OPTIONS += \ -DFLB_OUT_GELF=No \ -DFLB_OUT_INFLUXDB=No \ -DFLB_OUT_KAFKA=No \ + -DFLB_OUT_KAFKA_REST=No \ -DFLB_OUT_NRLOGS=No \ -DFLB_OUT_OPENSEARCH=No \ -DFLB_OUT_TD=No \ @@ -153,8 +147,6 @@ CMAKE_OPTIONS += \ -DFLB_OUT_FLOWCOUNTER=No \ -DFLB_OUT_LOGDNA=No \ -DFLB_OUT_LOKI=No \ - -DFLB_OUT_KAFKA=No \ - -DFLB_OUT_KAFKA_REST=No \ -DFLB_OUT_CLOUDWATCH_LOGS=No \ -DFLB_OUT_KINESIS_FIREHOSE=No \ -DFLB_OUT_KINESIS_STREAMS=No \ @@ -170,11 +162,10 @@ CMAKE_OPTIONS += \ define Package/fluent-bit/install $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_DIR) $(1)/etc/fluent-bit - $(INSTALL_DIR) $(1)/etc/fluent-bit/conf.d $(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/fluent-bit $(1)/usr/sbin/ - $(INSTALL_DATA) ./files/fluent-bit.conf $(1)/etc/fluent-bit/fluent-bit.conf - $(INSTALL_DATA) $(PKG_BUILD_DIR)/conf/parsers.conf $(1)/etc/fluent-bit/parsers.conf + + $(INSTALL_DIR) $(1)/etc/fluent-bit + $(INSTALL_CONF) $(PKG_BUILD_DIR)/conf/parsers.conf $(1)/etc/fluent-bit/parsers.conf endef $(eval $(call BuildPackage,fluent-bit)) diff --git a/fluent-bit/patches/0020-fix_kmsg.patch b/fluent-bit/patches/0020-fix_kmsg.patch index 14b2774c8..faa13df7c 100644 --- a/fluent-bit/patches/0020-fix_kmsg.patch +++ b/fluent-bit/patches/0020-fix_kmsg.patch @@ -1,5 +1,5 @@ diff --git a/plugins/in_kmsg/in_kmsg.c b/plugins/in_kmsg/in_kmsg.c -index cd5c4cd17..15f105451 100644 +index fe372a9a2..6acb34893 100644 --- a/plugins/in_kmsg/in_kmsg.c +++ b/plugins/in_kmsg/in_kmsg.c @@ -36,7 +36,6 @@ @@ -10,15 +10,24 @@ index cd5c4cd17..15f105451 100644 #include "in_kmsg.h" -@@ -123,12 +122,17 @@ static inline int process_line(const char *line, +@@ -114,7 +113,7 @@ static inline int process_line(const char *line, + struct timeval tv; /* time value */ + int line_len; + uint64_t val; +- long pri_val; ++ unsigned long pri_val; + const char *p = line; + char *end = NULL; + struct flb_time ts; +@@ -124,12 +123,17 @@ static inline int process_line(const char *line, ctx->buffer_id++; errno = 0; -- val = strtol(p, &end, 10); -- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN)) -+ val = strtoul(p, &end, 10); -+ if ((errno == ERANGE && val == ULONG_MAX) - || (errno != 0 && val == 0)) { +- pri_val = strtol(p, &end, 10); +- if ((errno == ERANGE && (pri_val == INT_MAX || pri_val == INT_MIN)) ++ pri_val = strtoul(p, &end, 10); ++ if ((errno == ERANGE && pri_val == ULONG_MAX) + || (errno != 0 && pri_val == 0)) { goto fail; } @@ -28,17 +37,9 @@ index cd5c4cd17..15f105451 100644 + } + /* Priority */ - priority = FLB_KLOG_PRI(val); + priority = FLB_KLOG_PRI(pri_val); -@@ -144,24 +148,35 @@ static inline int process_line(const char *line, - } - p++; - -- val = strtoul(p, &end, 10); -- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN)) -+ val = strtoull(p, &end, 10); -+ if ((errno == ERANGE && val == ULLONG_MAX) - || (errno != 0 && val == 0)) { +@@ -152,6 +156,12 @@ static inline int process_line(const char *line, goto fail; } @@ -51,12 +52,7 @@ index cd5c4cd17..15f105451 100644 sequence = val; p = ++end; - /* Timestamp */ -- val = strtoul(p, &end, 10); -- if ((errno == ERANGE && (val == INT_MAX || val == INT_MIN)) -+ val = strtoull(p, &end, 10); -+ if ((errno == ERANGE && val == ULLONG_MAX) - || (errno != 0 && val == 0)) { +@@ -162,8 +172,14 @@ static inline int process_line(const char *line, goto fail; } @@ -68,6 +64,7 @@ index cd5c4cd17..15f105451 100644 tv.tv_sec = val/1000000; - tv.tv_usec = val - (tv.tv_sec * 1000000); + tv.tv_usec = val - ((uint64_t)tv.tv_sec * 1000000); ++ flb_time_set(&ts, ctx->boot_time.tv_sec + tv.tv_sec, tv.tv_usec * 1000);