Path: blob/main/docs/sources/flow/reference/components/discovery.file.md
5316 views
------discovery.file
discovery.file discovers files on the local filesystem using glob patterns and the doublestar library.
Usage
Arguments
The following arguments are supported:
| Name | Type | Description | Default | Required |
|---|---|---|---|---|
path_targets | list(map(string)) | Targets to expand; looks for glob patterns on the __path__ and __path_exclude__ keys. | yes | |
sync_period | duration | How often to sync filesystem and targets. | "10s" | no |
path_targets uses doublestar style paths.
/tmp/**/*.logwill match all subfolders oftmpand include any files that end in*.log./tmp/apache/*.logwill match only files in/tmp/apache/that end in*.log./tmp/**will match all subfolders oftmp,tmpitself, and all files.
Exported fields
The following fields are exported and can be referenced by other components:
| Name | Type | Description |
|---|---|---|
targets | list(map(string)) | The set of targets discovered from the filesystem. |
Each target includes the following labels:
__path__: Absolute path to the file.
Component health
discovery.file is only reported as unhealthy when given an invalid configuration. In those cases, exported fields retain their last healthy values.
Debug information
discovery.file does not expose any component-specific debug information.
Debug metrics
discovery.file does not expose any component-specific debug metrics.
Examples
This example discovers all files and folders under /tmp/logs. The absolute paths are used by loki.source.file.files targets.
Kubernetes
This example finds all the logs on pods and monitors them.