From 7d07a25121581954b9a66a83055631f8f54240bc Mon Sep 17 00:00:00 2001 From: Iwan Mikhajlov Date: Wed, 10 Sep 2025 12:57:17 +0300 Subject: [PATCH 1/4] Added log_level off and log_file definition support --- REFERENCE.md | 9 +++++++++ manifests/config.pp | 1 + manifests/init.pp | 3 ++- templates/fluentbit.conf.epp | 3 +++ types/loglevel.pp | 2 +- 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/REFERENCE.md b/REFERENCE.md index b7ca170..d22e593 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -84,6 +84,7 @@ The following parameters are available in the `fluentbit` class: * [`grace`](#-fluentbit--grace) * [`daemon`](#-fluentbit--daemon) * [`dns_mode`](#-fluentbit--dns_mode) +* [`log_file`](#-fluentbit--log_file) * [`log_level`](#-fluentbit--log_level) * [`http_server`](#-fluentbit--http_server) * [`http_listen`](#-fluentbit--http_listen) @@ -361,6 +362,14 @@ Data type: `Enum['UDP', 'TCP']` Sets the primary transport layer protocol used by the asynchronous DNS resolver. +##### `log_file` + +Data type: `Optional[Stdlib::Absolutepath]` + +Absolute path where Fluent Bit will write its diagnostic logs. +When specified, logs go to this file instead of syslog. +The file will be created by Fluent Bit automatically. + ##### `log_level` Data type: `Fluentbit::Loglevel` diff --git a/manifests/config.pp b/manifests/config.pp index f7219d0..2bcfec9 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -139,6 +139,7 @@ 'daemon' => bool2str($fluentbit::daemon, 'On', 'Off'), 'dns.mode' => $fluentbit::dns_mode, 'log_level' => $fluentbit::log_level, + 'log_file' => $fluentbit::log_file, 'http_server' => bool2str($fluentbit::http_server, 'On', 'Off'), 'http_listen' => $fluentbit::http_listen, 'http_port' => $fluentbit::http_port, diff --git a/manifests/init.pp b/manifests/init.pp index f5347fe..318bd97 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -195,7 +195,7 @@ # Sets the primary transport layer protocol used by the asynchronous DNS resolver. # @param log_level # Set the logging verbosity level. -# Values are: error, info, debug and trace. Values are accumulative, +# Values are: off, error, warn, info, debug, and trace. Values are accumulative, # e.g: if 'debug' is set, it will include error, info and debug. # Note that trace mode is only available if Fluent Bit was built with the WITH_TRACE option enabled. # @param http_server @@ -257,6 +257,7 @@ Boolean $daemon, Enum['UDP', 'TCP'] $dns_mode, Fluentbit::Loglevel $log_level, + Optional[Stdlib::Absolutepath] $log_file = undef, Boolean $manage_parsers_file, String $parsers_file, Boolean $manage_plugins_file, diff --git a/templates/fluentbit.conf.epp b/templates/fluentbit.conf.epp index 97d25f3..0147cb8 100644 --- a/templates/fluentbit.conf.epp +++ b/templates/fluentbit.conf.epp @@ -9,6 +9,9 @@ Grace <%= $service['grace'] %> dns.mode <%= $service['dns.mode'] %> Log_Level <%= $service['log_level'] %> +<% if $service['log_file'] { %> + Log_File <%= $service['log_file'] %> +<% } -%> parsers_file <%= $service['parsers_file'] %> plugins_file <%= $service['plugins_file'] %> streams_file <%= $service['streams_file'] %> diff --git a/types/loglevel.pp b/types/loglevel.pp index a3abc9f..439b30d 100644 --- a/types/loglevel.pp +++ b/types/loglevel.pp @@ -1 +1 @@ -type Fluentbit::Loglevel = Enum['error', 'warning', 'info', 'debug', 'trace'] +type Fluentbit::Loglevel = Enum['error', 'warning', 'info', 'debug', 'trace', 'off'] From 3009663f717ad7fabd4e490a287876148880457c Mon Sep 17 00:00:00 2001 From: Iwan Mikhajlov Date: Wed, 10 Sep 2025 15:35:35 +0300 Subject: [PATCH 2/4] warning loglevel fixup and log_file_config undef state implement --- manifests/config.pp | 9 +++++++-- manifests/init.pp | 4 +++- types/loglevel.pp | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 2bcfec9..42aab7d 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -132,6 +132,12 @@ 'hc.period' => $fluentbit::hc_period, }, } + $log_file_config = $fluentbit::log_file ? { + undef => {}, + default => { + 'log_file' => $fluentbit::log_file + }, + } $service_config = { 'flush' => $fluentbit::flush, @@ -139,7 +145,6 @@ 'daemon' => bool2str($fluentbit::daemon, 'On', 'Off'), 'dns.mode' => $fluentbit::dns_mode, 'log_level' => $fluentbit::log_level, - 'log_file' => $fluentbit::log_file, 'http_server' => bool2str($fluentbit::http_server, 'On', 'Off'), 'http_listen' => $fluentbit::http_listen, 'http_port' => $fluentbit::http_port, @@ -147,7 +152,7 @@ 'scheduler.cap' => $fluentbit::scheduler_cap, 'scheduler.base' => $fluentbit::scheduler_base, 'json.convert_nan_to_null' => $fluentbit::json_convert_nan_to_null, - } + $storage_config + $health_config + } + $storage_config + $health_config + $log_file_config if $fluentbit::format == 'classic' { $config_content = epp('fluentbit/fluentbit.conf.epp', diff --git a/manifests/init.pp b/manifests/init.pp index 318bd97..47e38f1 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -193,9 +193,11 @@ # Boolean value to set if Fluent Bit should run as a Daemon (background) or not. Allowed values are: yes, no, on and off. # @param dns_mode # Sets the primary transport layer protocol used by the asynchronous DNS resolver. +# @param log_file +# Specify the absolute path to the log file for Fuent Bit service itself # @param log_level # Set the logging verbosity level. -# Values are: off, error, warn, info, debug, and trace. Values are accumulative, +# Values are: off, error, warn, info, debug and trace. Values are accumulative, # e.g: if 'debug' is set, it will include error, info and debug. # Note that trace mode is only available if Fluent Bit was built with the WITH_TRACE option enabled. # @param http_server diff --git a/types/loglevel.pp b/types/loglevel.pp index 439b30d..c9f0e29 100644 --- a/types/loglevel.pp +++ b/types/loglevel.pp @@ -1 +1 @@ -type Fluentbit::Loglevel = Enum['error', 'warning', 'info', 'debug', 'trace', 'off'] +type Fluentbit::Loglevel = Enum['error', 'warn', 'info', 'debug', 'trace', 'off'] From facc3fa7fb6faf85e5f442e0314ba095c0e64d5e Mon Sep 17 00:00:00 2001 From: Iwan Mikhajlov Date: Wed, 10 Sep 2025 16:12:10 +0300 Subject: [PATCH 3/4] lint fix --- manifests/config.pp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 42aab7d..ec6cebc 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -134,8 +134,8 @@ } $log_file_config = $fluentbit::log_file ? { undef => {}, - default => { - 'log_file' => $fluentbit::log_file + default => { + 'log_file' => $fluentbit::log_file, }, } From 625f303d60624405fd6764b7d21f05ef0e17c7bf Mon Sep 17 00:00:00 2001 From: Iwan Mikhajlov Date: Wed, 10 Sep 2025 16:21:59 +0300 Subject: [PATCH 4/4] lint fix 2 --- manifests/init.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 47e38f1..8274f1a 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -259,7 +259,6 @@ Boolean $daemon, Enum['UDP', 'TCP'] $dns_mode, Fluentbit::Loglevel $log_level, - Optional[Stdlib::Absolutepath] $log_file = undef, Boolean $manage_parsers_file, String $parsers_file, Boolean $manage_plugins_file, @@ -301,6 +300,7 @@ Fluentbit::Stream $streams = {}, Array[Stdlib::Absolutepath] $plugins = [], Optional[String[1]] $memory_max = undef, + Optional[Stdlib::Absolutepath] $log_file = undef, Array[Stdlib::Absolutepath] $includes = [], ) { $pipelines_path = "${config_dir}/${pipelines_dir}"