diff --git a/_data/navigation.yml b/_data/navigation.yml index 63829f9e..d5da1bbd 100644 --- a/_data/navigation.yml +++ b/_data/navigation.yml @@ -142,8 +142,10 @@ admin-guide-nav: subnav: - title: "Notes on reading kernel messages" url: /admin-guide/060_Sources/020_File/000_Notes_on_reading_kernel_messages + - title: "How file sources are followed" + url: /admin-guide/060_Sources/020_File/001_File_following - title: "file() source options" - url: /admin-guide/060_Sources/020_File/001_File_source_options + url: /admin-guide/060_Sources/020_File/002_File_source_options - title: "Arr logs" url: /admin-guide/060_Sources/025_Arr_logs/README subnav: diff --git a/_includes/doc/admin-guide/options/follow-freq.md b/_includes/doc/admin-guide/options/follow-freq.md index 927b64a1..e8ab84f3 100644 --- a/_includes/doc/admin-guide/options/follow-freq.md +++ b/_includes/doc/admin-guide/options/follow-freq.md @@ -5,7 +5,10 @@ *Description:* Indicates that the source should be checked periodically. This is useful for files which always indicate readability, even though -no new lines were appended. If this value is higher than zero, syslog-ng -will not attempt to use poll() on the file, but checks whether the file -changed every time the follow-freq() interval (in seconds) has elapsed. +no new lines were appended (e.g. regular file system files). If this value +is higher than zero, syslog-ng will not attempt to use ivikys file change +notification methods on the file (poll(), epoll(), etc.), but checks whether +the file changed every time the follow-freq() interval (in seconds) has elapsed.\ Floating-point numbers (for example, **1.5**) can be used as well. + +{% include doc/admin-guide/warnings/file-source-follow-warning.md %} diff --git a/_includes/doc/admin-guide/warnings/file-source-follow-warning.md b/_includes/doc/admin-guide/warnings/file-source-follow-warning.md new file mode 100644 index 00000000..aea647e8 --- /dev/null +++ b/_includes/doc/admin-guide/warnings/file-source-follow-warning.md @@ -0,0 +1,2 @@ +![]({{ site.baseurl}}/assets/images/caution.png) **CAUTION:** As the follow-freq(), the monitor-method(), and the monitor-freq() options could have performance penalty effects, it is important to understand how the file and directory monitoring operates depending on these values. For details, refer to How content changes are followed in file() and wildcard-file() sources. +{: .notice--warning} diff --git a/_sass/minimal-mistakes/minimal-mistakes/_tables.scss b/_sass/minimal-mistakes/minimal-mistakes/_tables.scss index c270a775..2adace52 100644 --- a/_sass/minimal-mistakes/minimal-mistakes/_tables.scss +++ b/_sass/minimal-mistakes/minimal-mistakes/_tables.scss @@ -30,6 +30,9 @@ th { td { padding: 0.5em; border-bottom: 1px solid mix(#000, $border-color, 25%); + &.right-edged-col { + border-right: 1px solid mix(#000, $border-color, 25%); + } } tr, diff --git a/doc/_admin-guide/060_Sources/020_File/001_File_following.md b/doc/_admin-guide/060_Sources/020_File/001_File_following.md new file mode 100644 index 00000000..39ae4b46 --- /dev/null +++ b/doc/_admin-guide/060_Sources/020_File/001_File_following.md @@ -0,0 +1,164 @@ +--- +title: How content changes are followed in file() and wildcard-file() sources +short_title: How file sources are followed +id: adm-src-wild-follow +description: >- + The {{ site.product.short_name }} application can use various methods to detect changes + in the followed file() and wildcard-file() sources. Under the hood, two different change + watchers operate: one for detecting changes in the followed directories and one for + monitoring changes in the watched files. +--- + +The detection method for directory changes can be controlled via monitor-method(). If the method is `poll`, {{ site.product.short_name }} will set up an (ivykis) timer that periodically checks and compares the content of the given directory at the frequency specified by monitor-freq(). This periodic polling can be resource-intensive (mainly CPU), so selecting the proper value for monitor-freq() is important. This is not an issue on Linux, where you can use `inotify` for monitor-method(), which automatically notifies {{ site.product.short_name }} about changes with no significant resource usage impact. + +**NOTE:** For macOS and FreeBSD, a `kqueue` based implementation will be available in the near future, offering similar performance to `inotify` on Linux. Stay tuned! +{: .notice--info} + +Detecting file content changes involves more factors that can affect resource usage and overall performance. {{ site.product.short_name }} uses two main methods to monitor file content changes. + +The first method is automatically selected if the follow-freq() option has a value greater than 0. It works like the directory monitoring `poll` monitor-method() and uses an (ivykis) timer with the frequency of follow-freq(). It tries to detect changes in the file content (as well as state, file deletion, and moves) each time the timer fires. Similar to directory change monitoring, this process can be resource-intensive, so you should find the proper setting to balance performance, resource usage, and fault tolerance (such as avoiding log message loss). + +The second method is activated if the follow-freq() option is set to 0. It uses ivykis poll methods, sometimes resembling the poll method for directory change watching described above (with its performance penalties), but often working similarly to the `inotify` version (with seamless performance). + +The following table shows which method is selected in different cases. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

follow-freq()

+
+

file follow method

+
+

linux

+
+

macOS, FreeBSD

+
+

Solaris

+
+

0

+
+

ivykis poll

+
+

port-timer, port

+
+

n.a.

+
+

n.a.

+
+

should work
(not tested yet)

+
+

dev-poll

+
+

n.a.

+
+

n.a.

+
+

should work
(not tested yet)

+
+

epoll-timer, epoll

+
+

does not work

+
+

n.a.

+
+

should work
(not tested yet)

+
+

kqueue

+
+

n.a.

+
+

works

+
+

n.a.

+
+

ppoll

+
+

works, but always signals readability

+
+

n.a.

+
+

should work
(not tested yet)

+
+

poll

+
+

works, but always signals readability

+
+

works, but always signals readability

+
+

works, but always signals readability

+
+

> 0

+
+

syslog-ng poll
using ivykis timer with timer freq set to follow-freq() value

+
+

works

+
+

works

+
+

works

+
+ +A bit more detail about the notation in the platform columns and what they really mean: + +`n.a.` - Means that the feature is not supported on the given platform by default, which has a significant impact on how the final ivykis poll method is selected. Ivykis tries to set up (at initialization time) the method to be used in the order enumerated in the table above. If an option is `n.a.` (determined at build time), then the next option will be used automatically. The first available option will be used, and if it does not work on the given platform (see `does not work` below), then {{ site.product.short_name }} will stop that file source with an error. This can be controlled using the `IV_EXCLUDE_POLL_METHOD` environment variable. Methods enumerated in it will be excluded from the ivykis initialization flow, and the next available (and not excluded) one will be used. The strings that can be used in `IV_EXCLUDE_POLL_METHOD` are `port-timer port dev_poll epoll-timerfd epoll kqueue ppoll poll` in the same order as in the table.\ +e.g., on Linux you should use `IV_EXCLUDE_POLL_METHOD="epoll-timerfd epoll"` to force the usage of the `ppoll` method, as `port-timer port dev_poll` are not available, and `epoll-timerfd epoll` are not working currently. However, note that currently `ppoll` and `poll` are the only working options on Linux, and they are far from optimal, unlike on BSD-based systems like macOS, where the default `kqueue` is a perfect option to use. + + **NOTE:** We are planning to add an `inotify` or similar-based solution to ivykis that could perform similarly to `kqueue`. Stay tuned! + {: .notice--info} + +`works` - Means it is tested and works seamlessly (based on our tests). + +`works, but always signals readability` - Means that the method is available on the given platform, but it is primarily designed for sockets, pipes, and similar uses, not for regular files. For regular files, it is always triggered (because regular files are always readable), behaving similarly to the `poll` method of directory monitoring with all of its disadvantages. Moreover, it could lead to even higher resource consumption (mainly CPU load) because follow-freq() does not control the frequency of the triggered internal file checks, which could occur hundreds or thousands of times per second. + +`does not work` - Means that the method is available on the given platform but currently does not work as expected for various reasons. \ No newline at end of file diff --git a/doc/_admin-guide/060_Sources/020_File/001_File_source_options.md b/doc/_admin-guide/060_Sources/020_File/002_File_source_options.md similarity index 100% rename from doc/_admin-guide/060_Sources/020_File/001_File_source_options.md rename to doc/_admin-guide/060_Sources/020_File/002_File_source_options.md diff --git a/doc/_admin-guide/060_Sources/020_File/README.md b/doc/_admin-guide/060_Sources/020_File/README.md index 71161cd5..f10bce47 100644 --- a/doc/_admin-guide/060_Sources/020_File/README.md +++ b/doc/_admin-guide/060_Sources/020_File/README.md @@ -17,6 +17,8 @@ The file driver has a single required parameter specifying the file to open. If you want to use wildcards in the filename, use the [[wildcard-file() source|adm-src-wild]]. For the list of available optional parameters, see file() source options. +{% include doc/admin-guide/warnings/file-source-follow-warning.md %} + **Declaration** ```config diff --git a/doc/_admin-guide/060_Sources/030_Wildcard-file/000_Wildcard-file_options.md b/doc/_admin-guide/060_Sources/030_Wildcard-file/000_Wildcard-file_options.md index cbfc39d6..8a9f59fd 100644 --- a/doc/_admin-guide/060_Sources/030_Wildcard-file/000_Wildcard-file_options.md +++ b/doc/_admin-guide/060_Sources/030_Wildcard-file/000_Wildcard-file_options.md @@ -105,16 +105,28 @@ monitor. If the wildcard-file source matches more files than the value of the max-files() option, it is random which files will {{ site.product.short_name }} actually monitor. The default value of max-files() is 100. +## monitor-freq() + +|Type: | number | +|Default: | value of follow-freq() | + +*Description:* Indicates how frequently changes to the source file creation, move, or deletion should be checked if monitor-method() is set to `poll`.\ +Floating-point numbers (for example, **1.5**) can be used as well. Please note, for backward compatibility reasons, the default value of monitor-freq() is equal to the value of follow-freq(). + +{% include doc/admin-guide/warnings/file-source-follow-warning.md %} + ## monitor-method() -|Accepted values:| auto \| inotify \| poll| -|Default:| auto| +|Accepted values:| auto \| inotify \| poll| +|Default: | auto | *Description:* If the platform supports inotify, {{ site.product.short_name }} uses it -automatically to detect changes to the source files. If inotify is not -available, {{ site.product.short_name }} polls the files as set in the follow-freq() -option. To force {{ site.product.short_name }} poll the files even if inotify is -available, set this option to **poll**. +automatically to detect creation, move, or deletion of the source files. If inotify is not +available, {{ site.product.short_name }} polls the above mentioned file changes as set in +the monitor-freq() option. To force {{ site.product.short_name }} poll the file changes even if +inotify is available, set this option to **poll**. + +{% include doc/admin-guide/warnings/file-source-follow-warning.md %} {% include doc/admin-guide/options/multi-line-garbage.md %} @@ -154,8 +166,9 @@ source s_file_subdirectories { base-dir("/var/log") filename-pattern("*.log") recursive(yes) + monitor-freq(0.5) follow-freq(1) - log-fetch-limit(100) + log-fetch-limit(200) ); }; ``` diff --git a/doc/_admin-guide/060_Sources/030_Wildcard-file/README.md b/doc/_admin-guide/060_Sources/030_Wildcard-file/README.md index d7a86c6c..1ce9b8a3 100644 --- a/doc/_admin-guide/060_Sources/030_Wildcard-file/README.md +++ b/doc/_admin-guide/060_Sources/030_Wildcard-file/README.md @@ -17,6 +17,8 @@ persist file depends on the package you installed {{ site.product.short_name }} typically it is /var/lib/syslog-ng/syslog-ng.persist or /var/lib/syslog-ng/syslog-ng.persist. +{% include doc/admin-guide/warnings/file-source-follow-warning.md %} + **Declaration** ```config