File Storage Overview
TheFILE_STORAGE connector writes MQTT messages to local CSV or JSON files. It provides simple persistence for logging, backups, and data export without requiring a database server.
File storage is ideal for simple logging, local backups, and exporting data for offline analysis. Use it when you don’t need a full database but want persistent records.
Basic Syntax
Connection Configuration
FILE_STORAGE_CONFIG Parameters
Directory for the files. Use a relative path such as
"logs": it resolves under the broker’s storage root, so the same connector works on every host. See Where files are written.Storage Location Options
Storage Location Options
Format
Format
Write Options
Write Options
Where files are written
A relativeSTORAGE_DIR resolves under the broker’s storage root, the storage folder in the broker’s data directory. Files then live with the rest of the broker’s data. In Docker, that is the data volume, so they survive a container recreate.
Setting
COREFLUX_DATA_PATH (or CONFIG_PATH) moves the storage root with the data directory.
The broker always refuses a
STORAGE_DIR that points at the data directory itself, the install directory, or the broker’s own bin/, config/, projects/, log/, logs/, stats/, or cluster/ folders. A FILE_PATTERN, or a table name from an event query, that would place a file outside STORAGE_DIR (with .. or an absolute path) is refused too.
Set the environment variable COREFLUX_STORAGE_RESTRICT_TO_ROOT=true to refuse every path outside the storage root, including absolute paths and the working-directory fallback. It is off by default so existing connectors with absolute paths keep working. Turn it on where AI assistants deploy connectors.
Deploy checks the folder
When you add aFILE_STORAGE connector, the broker resolves STORAGE_DIR, creates the folder, and writes a test file before it accepts the connector. If that fails, the error names the storage root and a relative path to retry with:
get_storage_locations tool first. It reports the OS, whether the broker runs in a container, the data directory and storage root (each with a write check and free space), and a recommended relative STORAGE_DIR.
CLEAN Query Format
File storage connectors use the CLEAN format:table name is used in the file pattern with {0}.
Writing Data
- CSV Logging
- JSON Storage
- Multiple Files
- Backup Storage
Log sensor data to daily CSV files:Creates
sensor_data.csv under the storage root’s logs folder.Alternative: STORE IN with Models — Instead of writing EVENT queries, you can bind a model directly to this connector. Every See Data Storage Overview for the full STORE IN workflow.
PUBLISH MODEL call automatically inserts a row — no query needed:Reading Data
EVENTs also support read queries to retrieve data from stored files. Publish a message to the event’sSOURCE_TOPIC, and the matching rows are published to DESTINATION_TOPIC as one JSON array. File Storage read queries use the CLEAN format with filter, sort, and limit instead of SQL.
A query is a store when its object has a top-level data key, and a read otherwise. A filter or projection that names a field called data is still a read. filter, sort, skip, limit, and projection apply to CSV and JSON files alike. CSV cells are compared as numbers when the value in the filter is a number, so {count: {$gte: 7}} works on a CSV file.
file/result/latest, where your actions or external clients can consume it.
One connector can store and read the same table. The automatic column is timestamp, so sort by it to get the newest rows:
historian/packer01/query to get the 100 newest rows on historian/packer01/result. An assistant on the MCP Server can run the read event directly with run_connector (target: Packer01History.QueryPacker01State).
CLEAN Read Operators
limit is applied before skip: limit: 10, skip: 5 returns rows 6 to 10 of the result.
File Pattern Placeholders
{0} is the only supported placeholder. A pattern with others, such as {date}, fails when the connector writes.
Output Examples
CSV Output
JSON Output (JSON Lines format)
Troubleshooting
Permission Denied
Permission Denied
- Use a relative
STORAGE_DIRso files go under the storage root. See Where files are written - For an absolute path, check that the folder exists and that the broker process can write there
- Read the deploy error: it names the storage root and a relative path to retry with
File Not Created
File Not Created
- Check where a relative
STORAGE_DIRresolves on this host in Where files are written - Look for a deprecation warning in the log: an older relative folder under the working directory is still used
- Check disk space is available
Data Not Appearing
Data Not Appearing
- Verify SOURCE_TOPIC matches incoming messages
- Check QUERY syntax is correct
- Verify APPEND is set correctly
Connector fails to write
Connector fails to write
FILE_PATTERNaccepts only{0}(the table name). Remove other placeholders such as{date}.- For JSON,
MAX_RECORDScaps the file and drops the oldest records. Files are not rotated.
Next Steps
Data Storage Connectors Overview
Compare all storage options.
PostgreSQL Connector
Configure PostgreSQL database storage.

