You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 33b68e6
Browse filesBrowse the repository at this point in the historyBrowse files
- Add the windows.absolute_dynamic_path parameter to the table.
- Add a Windows absolute paths section: the fixed drive-absolute
directory and startup error, per-record checks on the path and
filename, on_missing_field handling, empty values, fallback_path,
and record accessor placement, with an example.
- Link the new section from the unsafe destination rules.
- Tag-derived names: separators at the start or end of the tag
are removed first; only separators between other characters
are rejected.
- Empty accessor values: the whole resolved path is checked, so
the result depends on the text around the accessor.
- Accessor placement: literal text can follow an accessor when it
starts with a period, space, comma, or double quote.
Refs fluent/fluent-bit#12812
Signed-off-by: Eric D. Schabell <eric@schabell.org>
Copy file name to clipboardExpand all lines: pipeline/outputs/file.md
+68-1Lines changed: 68 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ The _File_ output plugin lets you write the data received through the input plug
25
25
|`rotate_gzip`| Compress rotated files using gzip. Only applies when `rotate` is enabled. |`true`|
26
26
|`rotate_max_files`| Maximum number of rotated files to retain per output file. Oldest files are deleted first. Must be `1` or greater. Only applies when `rotate` is enabled. |`7`|
27
27
|`rotate_max_size`| Maximum size of the active output file before rotation is triggered. Supports size suffixes: `k` (kilobytes), `m` (megabytes), `g` (gigabytes). Only applies when `rotate` is enabled. |`100M`|
28
+
|`windows.absolute_dynamic_path`| Windows only. Require a dynamic `path` to start with a fixed drive-absolute directory, such as `C:\logs\`, and keep record accessor values from adding directory levels. See [Windows absolute paths](#windows-absolute-paths). |`false`|
28
29
|`workers`| The number of [workers](../../administration/multithreading.md#outputs) to perform flush operations for this output. |`1`|
29
30
30
31
## Format
@@ -218,7 +219,7 @@ Two rules apply when you configure a dynamic destination:
218
219
- A `path` that uses a record accessor must begin with a static prefix. Fluent Bit rejects a `path` that starts with a record accessor, so that generated paths always stay under a directory you chose. This check doesn't apply to `strftime` placeholders. See [`strftime` placeholders](#strftime-placeholders).
219
220
- You must set `fallback_file`. Fluent Bit fails to start if a record accessor or a `strftime` placeholder is used without it, because there would be nowhere to write records whose destination can't be resolved.
220
221
221
-
Fluent Bit rejects a resolved destination as unsafe when the filename is empty, is `.` or `..`, or contains a path separator or one of the characters `:`, `*`, `?`, `"`, `<`, `>`, or `|`. Path components of `.` and `..` are also rejected. This keeps a record value from redirecting output outside of the configured directory.
222
+
Fluent Bit rejects a resolved destination as unsafe when the filename is empty, is `.` or `..`, or contains a path separator or one of the characters `:`, `*`, `?`, `"`, `<`, `>`, or `|`. Path components of `.` and `..` are also rejected. This keeps a record value from redirecting output outside of the configured directory. On Windows, `windows.absolute_dynamic_path` adds stricter checks. See [Windows absolute paths](#windows-absolute-paths).
222
223
223
224
Generated directories are only created if you also enable `mkdir`.
224
225
@@ -246,6 +247,72 @@ Most rules described in [Dynamic destinations](#dynamic-destinations) apply to p
246
247
247
248
The static prefix requirement is the exception. Fluent Bit enforces it for record accessors only, so a `path` can begin with a placeholder. A `path` of `%Y/%m/%d` resolves to a relative directory such as `2026/08/17`, located inside the Fluent Bit working directory. Begin the value with a static prefix, as in `/var/log/fluent-bit/%Y/%m/%d`, to keep output under a directory you chose.
248
249
250
+
### Windows absolute paths
251
+
252
+
On Windows, set `windows.absolute_dynamic_path` to `true` to apply stricter checks to a dynamic `path`. The parameter has no effect on other platforms, or when `path` isn't dynamic.
253
+
254
+
At startup, Fluent Bit takes the fixed directory at the start of `path`: the text before the first record accessor, or before the first `%` when `enable_strftime` is `true`, up to and including its last path separator. That directory must meet these rules:
255
+
256
+
- It starts with a drive letter, a colon, and a separator, such as `C:\` or `C:/`. Universal Naming Convention (UNC) paths such as `\\server\share\`, device paths such as `\\?\C:\`, drive-relative paths such as `C:logs\`, and relative paths aren't accepted.
257
+
- It doesn't contain two separators in a row, or a component that ends with a period or a space.
258
+
- After the drive, it doesn't contain control characters or any of the characters `:`, `*`, `?`, `"`, `<`, `>`, or `|`.
259
+
260
+
If the directory doesn't meet these rules, Fluent Bit fails to start and logs `'windows.absolute_dynamic_path' requires a fixed drive-absolute directory before the first dynamic 'path' placeholder`. This check runs before the static prefix check, so a `path` that starts with a record accessor also fails with this message.
261
+
262
+
For each record, Fluent Bit also rejects the resolved destination as unsafe in these cases:
263
+
264
+
- The resolved path doesn't meet the same rules, or doesn't start with the fixed directory exactly as configured.
265
+
- A record accessor value in `path` contains a path separator. Only the literal text of `path`, including text produced by `strftime` placeholders, can separate directories, so record values can't add directory levels.
266
+
- The filename is empty, is `.` or `..`, or ends with a period or a space. Windows can remove trailing periods and spaces when it resolves a path.
267
+
- The filename contains a path separator, a control character, a null character, or one of the characters `:`, `*`, `?`, `"`, `<`, `>`, or `|`.
268
+
- These filename checks also apply to a static `file` value and to a name derived from the tag. When `file` isn't set, Fluent Bit first removes `/` and `\` characters at the start or end of the tag, so a tag that still contains `/` or `\` between other characters is rejected.
269
+
270
+
A record accessor value that's an empty string isn't rejected by itself, because Fluent Bit checks the whole resolved path. With `path` set to `C:\logs\$namespace`, an empty value writes the record to `C:\logs\` itself. With `C:\logs\app-$namespace`, it writes the record to a directory named `app-`. If the empty value leaves the path ending with a period or a space, the destination is rejected.
271
+
272
+
A rejected destination is handled by `on_missing_field`, the same as other unsafe destinations. See [Actions for unresolved destinations](#actions-for-unresolved-destinations). These rules don't apply to `fallback_path`, so set it to an absolute directory, as in the following example.
273
+
274
+
A record accessor name ends at the first period, space, comma, or double quote, so literal text after an accessor must start with one of these characters, as in `C:\logs\$namespace.d`. A record accessor followed directly by `\` fails at startup with `invalid record accessor pattern set for 'path'`, and a record accessor followed directly by `/` is read as part of the field name.
275
+
276
+
The following configuration writes each record to a per-namespace directory inside `C:\logs\`:
277
+
278
+
{% tabs %}
279
+
{% tab title="fluent-bit.yaml" %}
280
+
281
+
```yaml
282
+
pipeline:
283
+
outputs:
284
+
- name: file
285
+
match: '*'
286
+
path: 'C:\logs\$namespace'
287
+
file: app.log
288
+
mkdir: true
289
+
windows.absolute_dynamic_path: true
290
+
on_missing_field: fallback
291
+
fallback_path: 'C:\logs'
292
+
fallback_file: unrouted.log
293
+
```
294
+
295
+
{% endtab %}
296
+
{% tab title="fluent-bit.conf" %}
297
+
298
+
```text
299
+
[OUTPUT]
300
+
Name file
301
+
Match *
302
+
Path C:\logs\$namespace
303
+
File app.log
304
+
Mkdir true
305
+
Windows.Absolute_Dynamic_Path true
306
+
On_Missing_Field fallback
307
+
Fallback_Path C:\logs
308
+
Fallback_File unrouted.log
309
+
```
310
+
311
+
{% endtab %}
312
+
{% endtabs %}
313
+
314
+
With this configuration, a record with `namespace` set to `web` is written to `C:\logs\web\app.log`. A record with `namespace` set to `web\admin` or `web/admin` is written to `C:\logs\unrouted.log`, because the value adds a directory level.
315
+
249
316
### Actions for unresolved destinations
250
317
251
318
Two settings control what happens to a record whose destination Fluent Bit can't use. `on_missing_field` applies when the record accessor field is missing or resolves to an unsafe value, and `on_limit_reached` applies when writing to a new destination would exceed `max_dynamic_files`. Both accept the same actions:
0 commit comments