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
Copy file name to clipboardExpand all lines: docs/sources/reference/components/local/local.file_match.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,8 @@ The `__path__` field uses [doublestar][] style glob patterns:
57
57
*`/tmp/**/*.log` matches all subdirectories of `tmp` and include any files that end in `*.log`.
58
58
*`/tmp/apache/*.log` matches only files in `/tmp/apache/` that end in `*.log`.
59
59
*`/tmp/**` matches all subdirectories of `tmp`, `tmp` itself, and all files.
60
+
*`/tmp/*.{log,txt,json}` matches files with `.log`, `.txt`, or `.json` extensions in `/tmp/`.
61
+
*`/var/log/{nginx,apache}/*.log` matches `.log` files in either the `nginx` or `apache` subdirectories.
60
62
61
63
`local.file_match` doesn't ignore files when you set `ignore_older_than` to the default, `0s`.
62
64
@@ -181,6 +183,35 @@ Replace the following:
181
183
*_`<USERNAME>`_: The username to use for authentication to the Loki API.
182
184
*_`<PASSWORD>`_: The password to use for authentication to the Loki API.
183
185
186
+
### Match multiple patterns
187
+
188
+
This example shows how to use the `{a,b,c}` pattern syntax to match multiple file extensions, multiple directories, and exclude multiple file types in a single configuration.
189
+
190
+
```alloy
191
+
local.file_match "logs" {
192
+
path_targets = [
193
+
// Match .log, .txt, and .json files from nginx, apache, or caddy directories
Copy file name to clipboardExpand all lines: docs/sources/reference/components/loki/loki.source.file.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,11 @@ Benefits of using `file_match` over `local.file_match`:
142
142
When `enabled` is set to `true`, you can use glob patterns, for example, `/tmp/*.log` or `/var/log/**/*.log`, directly in the `targets` argument's `__path__` label.
143
143
The component periodically scans the filesystem based on `sync_period` and automatically discovers new files, removes deleted files, and ignores files older than `ignore_older_than` if specified.
144
144
145
+
The glob patterns support the `{a,b,c}` syntax for matching multiple alternatives:
146
+
147
+
*`/tmp/*.{log,txt,json}` matches files with `.log`, `.txt`, or `.json` extensions.
148
+
*`/var/log/{nginx,apache}/*.log` matches `.log` files in either the `nginx` or `apache` subdirectories.
149
+
145
150
## Exported fields
146
151
147
152
`loki.source.file` doesn't export any fields.
@@ -262,6 +267,34 @@ loki.write "local" {
262
267
}
263
268
```
264
269
270
+
### Match multiple patterns
271
+
272
+
This example shows how to use the `{a,b,c}` pattern syntax to match multiple file extensions, multiple directories, and exclude multiple file types in a single configuration.
273
+
274
+
```alloy
275
+
loki.source.file "logs" {
276
+
targets = [
277
+
// Match .log, .txt, and .json files from nginx, apache, or caddy directories
0 commit comments