files
The files read, and how their records map to the world.
- Type
- list
- Default
- required
User guideWayseer 0.28.3Contents
The file module reads CSV and JSON files and turns their records into entities, links, metrics and events, as a mapping in the config says. Use it for an inventory kept in a spreadsheet, an export from another tool, or a recording. It reads the files again when they change. The demo world is made this way.
modules:
- kind: file
name: inventory
options:
files:
- path: ~/fleet/hosts.csv
entities:
kind: host
id: hostname
status: state
reason: note
attrs: [os, cores, memory]
units: {memory: bytes}
tags: tags
edges:
- {rel: depends_on, to: depends, kind: host}
- path: ~/fleet/services.json
records: data.services
entities: {kind: service, id: id, attrs: [meta.owner]}
- path: ~/fleet/cpu.csv
series:
kind: host
id: host
time: ts
metrics:
cpu.utilisation: {field: cpu, unit: percent}
- path: ~/fleet/changes.csv
events:
kind: host
id: host
time: ts
severity: level
type: what
message: text
fields: [version]
With this hosts.csv:
hostname,state,note,os,cores,memory,tags,depends
web-01,ok,,linux,8,17179869184,prod;edge,db-01
db-01,warn,disk 91% full,linux,32,68719476736,prod,
there are two hosts, web-01 depending on db-01, and db-01 shows as warn with its reason. Detail shows db-01's memory as 64 GiB.
Each file maps its records to entities, series, events, or any of them together. The format comes from the extension (.csv, .tsv or .json) unless format says.
meta.owner.;. JSON uses an array.host or depends_on, with at most one prefix, such as acme/rack. The relations the lenses know are runs_on, depends_on, talks_to, member_of, owns and parent_of.ok, warn, crit, down or unknown.units gives a numeric attribute its unit, by field: bytes, bytes_per_second, bits, bits_per_second, percent, ratio (0 to 1, shown as a percentage), seconds, count or per_second. Detail then shows 64 GiB rather than 68719476736, and a filter can say memory>32GiB.2026-09-01T10:00:00Z, or Unix seconds.The options below go under options.
files
The files read, and how their records map to the world.
files[].path
The file; ~/ is the home directory.
files[].format
The format: csv, tsv or json.
files[].delimiter
CSV only: the field separator.
files[].records
JSON only: dotted path to the array of records.
files[].entities
Each record as an entity.
files[].entities.kind
The entities' kind, such as host or service.
files[].entities.id
The field holding each entity's id.
files[].entities.name
The field holding its name.
files[].entities.status
The field holding ok, warn, crit, down or unknown.
files[].entities.reason
The field explaining the status.
files[].entities.attrs
Fields kept as attributes.
files[].entities.units
The unit of a numeric attribute, by its field: bytes, seconds, percent and so on.
files[].entities.tags
The field holding its tags.
files[].entities.edges
Links from each entity to others.
files[].entities.edges[].rel
The relation, such as depends_on or parent_of.
files[].entities.edges[].to
The field holding the ids it links to.
files[].entities.edges[].kind
The kind of the entities it links to.
files[].entities.edges[].rate
The field holding each link's traffic per second, in the order of to.
files[].entities.edges[].unit
The traffic's unit: requests, bytes or messages; required with rate.
files[].series
Each record as samples of metrics.
files[].series.kind
The kind of the entity each record is about.
files[].series.id
The field holding that entity's id.
files[].series.time
The field holding the time, RFC 3339 or Unix seconds.
files[].series.metrics
Metric name to its field and unit.
files[].series.metrics.<name>.field
The field holding the value.
files[].series.metrics.<name>.unit
The unit: bytes, bytes_per_second, bits, bits_per_second, percent, ratio, seconds, count or per_second.
files[].events
Each record as an event.
files[].events.kind
With id, the kind of the entity each event is about.
files[].events.id
The field holding that entity's id; an empty cell makes a global event.
files[].events.time
The field holding the time, RFC 3339 or Unix seconds.
files[].events.severity
The field holding debug, info, warn, error or critical.
files[].events.type
The field holding its type, such as deploy or alert.
files[].events.message
The field holding its message.
files[].events.fields
Fields kept on the event.
rescan
How often to check files the watcher may have missed.
replay
Move recorded times so the newest is when the files were first loaded.
A metric's unit is one of bytes, bytes_per_second, bits, bits_per_second, percent, ratio (0 to 1), seconds, count or per_second. Without one, the number shows as it is. A metric name used in more than one file must have the same unit in each.
An edge can carry traffic: how much flows along it each second. rate names the field holding one rate for each id in to, in the same order, and unit says what is counted: requests, bytes or messages. With this services.csv:
id,calls,call_rates
web,api;auth,120;4.5
api,,
and the mapping
edges:
- {rel: talks_to, to: calls, kind: service, rate: call_rates, unit: requests}
web talks to api at 120 requests a second and to auth at 4.5. An empty rate cell means no traffic is known. A record whose rates are not numbers, are negative, or do not match its ids one for one is skipped and reported like any other bad record. The rate is the traffic now; a file holds no history of it, so edit the file to change it. The demo's talks_to edges carry rates this way.
The module watches the files and reads a file again soon after it changes, and every rescan in case a change was missed. A record that cannot be read, such as a row with a missing id or a time it cannot parse, is skipped. It is reported once, as a warn event naming the file and the line. A missing or unreadable file shows in the module's health, and the entities it gave are removed until it can be read again.
With replay: true, every time in the files moves by the same amount, so that the newest lands at the moment the files were first loaded. A recording made last week then shows as if it had just happened, which suits demos. The shift is fixed at the first load, so a file that changes later keeps its times in step with the rest.