logmngr: add support for including config files in fluent-bit

* config files can be placed at /etc/fluent-bit/conf.d/ and
  they will be included
This commit is contained in:
Mohd Husaam Mehdi 2025-05-22 22:44:55 +05:30
parent 99821b5010
commit 971d1ca37e
2 changed files with 10 additions and 0 deletions

View file

@ -170,6 +170,7 @@ 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

View file

@ -5,6 +5,7 @@
CONF_FILE=/etc/fluent-bit/fluent-bit.conf
TMP_CONF_FILE=/tmp/fluent-bit/fluent-bit.conf
CONF_DIR=/etc/fluent-bit/conf.d
append_conf() {
echo "$*" >> ${TMP_CONF_FILE}
@ -14,6 +15,14 @@ create_config_file() {
mkdir -p /tmp/fluent-bit
rm -f ${TMP_CONF_FILE}
touch ${TMP_CONF_FILE}
# include all files placed in CONF_DIR directory
# fluent-bit does not support using directory in include directive
# also, if no file is found then fluent-bit aborts
# so only add include if any file is present in the CONF_DIR
if [ -d "$CONF_DIR" ] && [ "$(ls -A "$CONF_DIR")" ]; then
echo "@INCLUDE ${CONF_DIR}/*" >> ${TMP_CONF_FILE}
fi
echo "" >> ${TMP_CONF_FILE}
}
create_service_section() {