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 b4da25e
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.
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
@@ -24,6 +24,7 @@ The _File_ output plugin lets you write the data received through the input plug
24
24
|`rotate_gzip`| Compress rotated files using gzip. Only applies when `rotate` is enabled. |`true`|
25
25
|`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`|
26
26
|`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`|
27
+
|`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`|
27
28
|`workers`| The number of [workers](../../administration/multithreading.md#outputs) to perform flush operations for this output. |`1`|
28
29
29
30
## Format
@@ -205,7 +206,7 @@ Two rules apply when you configure a dynamic destination:
205
206
- 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).
206
207
- 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.
207
208
208
-
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.
209
+
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).
209
210
210
211
Generated directories are only created if you also enable `mkdir`.
211
212
@@ -233,6 +234,72 @@ Most rules described in [Dynamic destinations](#dynamic-destinations) apply to p
233
234
234
235
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.
235
236
237
+
### Windows absolute paths
238
+
239
+
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.
240
+
241
+
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:
242
+
243
+
- 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.
244
+
- It doesn't contain two separators in a row, or a component that ends with a period or a space.
245
+
- After the drive, it doesn't contain control characters or any of the characters `:`, `*`, `?`, `"`, `<`, `>`, or `|`.
246
+
247
+
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.
248
+
249
+
For each record, Fluent Bit also rejects the resolved destination as unsafe in these cases:
250
+
251
+
- The resolved path doesn't meet the same rules, or doesn't start with the fixed directory exactly as configured.
252
+
- 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.
253
+
- 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.
254
+
- The filename contains a path separator, a control character, a null character, or one of the characters `:`, `*`, `?`, `"`, `<`, `>`, or `|`.
255
+
- These filename checks also apply to a static `file` value and to a name derived from the tag. When `file` isn't set, a tag that contains `/` or `\` is rejected.
256
+
257
+
A record accessor value that's an empty string isn't rejected. The record is written to the fixed directory itself.
258
+
259
+
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.
260
+
261
+
A record accessor must be the last part of `path`. A record accessor followed by `\` fails at startup with `invalid record accessor pattern set for 'path'`, and a record accessor followed by `/` is read as part of the field name.
262
+
263
+
The following configuration writes each record to a per-namespace directory inside `C:\logs\`:
264
+
265
+
{% tabs %}
266
+
{% tab title="fluent-bit.yaml" %}
267
+
268
+
```yaml
269
+
pipeline:
270
+
outputs:
271
+
- name: file
272
+
match: '*'
273
+
path: 'C:\logs\$namespace'
274
+
file: app.log
275
+
mkdir: true
276
+
windows.absolute_dynamic_path: true
277
+
on_missing_field: fallback
278
+
fallback_path: 'C:\logs'
279
+
fallback_file: unrouted.log
280
+
```
281
+
282
+
{% endtab %}
283
+
{% tab title="fluent-bit.conf" %}
284
+
285
+
```text
286
+
[OUTPUT]
287
+
Name file
288
+
Match *
289
+
Path C:\logs\$namespace
290
+
File app.log
291
+
Mkdir true
292
+
Windows.Absolute_Dynamic_Path true
293
+
On_Missing_Field fallback
294
+
Fallback_Path C:\logs
295
+
Fallback_File unrouted.log
296
+
```
297
+
298
+
{% endtab %}
299
+
{% endtabs %}
300
+
301
+
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.
302
+
236
303
### Actions for unresolved destinations
237
304
238
305
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