MetricsHub
MetricsHub Community Connectors 1.0.24
-
Home
- Connector Developer Guide Sources 21
file (Source)
When To Use
Use file to ingest file contents directly when available in your runtime version.
Typical intent:
- Tail-style log ingestion.
- Reading rotating files with wildcard paths.
- Full-file polling for small structured files.
Syntax
sources:
appLogs:
type: file
paths:
- /var/log/myapp/*.log
mode: LOG
maxSizePerPoll: 5MB
Properties
| Property | Required | Default | Description |
|---|---|---|---|
type |
Yes | None | file. |
paths |
Yes | None | File path patterns to read. Wildcards (* and ?) are supported in any segment, directory or filename (one segment at a time, ** is not supported). A path ending with a delimiter (/var/log/, C:\logs\) lists all files of the directory. An invalid path is skipped without discarding the other paths. |
mode |
No | LOG |
LOG (cursor/incremental) or FLAT (read full file each cycle). A job that reads a LOG source never removes its instances (see below). |
maxSizePerPoll |
No | 5242880 |
Max bytes read per cycle (-1 for unlimited). |
executeForEachEntryOf |
No | None | Fan-out execution context. |
computes |
No | [] |
Post-processing computes. |
forceSerialization |
No | false |
Serialize execution via a per-connector, per-host lock (see the Sources overview). Default false. |
Recommended Pattern
- Prefer
LOGmode for real log files. - Keep
maxSizePerPollbounded to avoid long polling delays. - Normalize lines with computes before mapping.
A discovery or simple job that reads a file source in LOG mode, directly or through ${source::...} references, never removes its instances: the source only returns the lines added since the previous poll, so a missing row does not mean a missing entity. FLAT mode is not incremental: a rotated or truncated file that returns fewer rows removes the instances of the missing rows (MetricsHub Community 3.9.08 or later, see When Instances Are Removed[1]).
Common Mistakes
- Using
FLATmode on large files. - Very broad wildcards that match too many files.
- Mapping raw unparsed text without stable separators.
Examples
No current community connector uses file.
file is present in the official JSON schema, but usage is currently absent in community connectors. Validate behavior against your MetricsHub runtime version before adopting it.
- [1] ../monitors-and-jobs.html#when-instances-are-removed
