File Storage Overview
TheFILE_STORAGE route 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 path for storing files.
Storage Location Options
Storage Location Options
File name pattern. Use
{0} for table name, {date} for current date. Default: {0}.csvFormat
Format
Write Options
Write Options
Timestamp
Timestamp
Timestamp format string. Default:
yyyy-MM-dd HH:mm:ss.CLEAN Query Format
File storage routes 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 files like:
sensor_data_2025-01-15.csvAlternative: STORE IN with Models — Instead of writing EVENT queries, you can bind a model directly to this route. 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 query result is published to DESTINATION_TOPIC. File Storage read queries use the CLEAN format with filter, sort, and limit instead of SQL:
file/result/latest, where your actions or external clients can consume it.
CLEAN Read Operators
File Pattern Placeholders
Output Examples
CSV Output
JSON Output (JSON Lines format)
Troubleshooting
Permission Denied
Permission Denied
- Verify STORAGE_DIR exists
- Check write permissions on directory
- Ensure Coreflux process has access
File Not Created
File Not Created
- Verify STORAGE_DIR path is correct
- Check disk space is available
- Ensure directory is writable
Data Not Appearing
Data Not Appearing
- Verify SOURCE_TOPIC matches incoming messages
- Check QUERY syntax is correct
- Verify APPEND is set correctly
File Rotation Issues
File Rotation Issues
- Check MAX_RECORDS is set appropriately
- Verify FILE_PATTERN includes
{date}for daily rotation
Next Steps
Data Storage Routes Overview
Compare all storage options.
PostgreSQL Route
Configure PostgreSQL database storage.

