Skip to content

Keep the historian within its disk budget

eaxScadaHow-to guideStarterProEnterpriseView as Markdown

Migrated page, not yet verified against the current code. Treat values, paths and examples as indicative until this notice is removed.

The historian never fills the disk of the machine it runs on. It keeps history for as long as you decide. It warns you, through system alarms and System Health, before space runs short. When the disk is critically full, it deletes its oldest days first and then stops writing history, while tag values, alarms and control go on. Closed days can be exported every night to Parquet files for long-term storage elsewhere.

  • Access to the server’s config file (config/config.yaml next to the server) and the right to restart the server.
  • A Lead_Engineer or Administrator account to see System Health and the storage status.
  • An idea of how much history you need online (for example 90 days) and how much disk you can give the historian (for example 50 GB).

New installs are written with a disk budget. Every shipped config file (the Linux and Windows archives, the Docker images, the appliance and the high-availability sample) sets:

Key Linux archive, appliance, community image Windows archive, Pro Docker image, high-availability sample
retention 90d 90d
max_size 10GB 20GB
disk.warn_free 15% 15%
disk.critical_free 5%, 2GB 5%, 5GB
disk.purge_on_critical, disk.pause_on_critical true true
logging defaults 1s, deadband 0, 10m 1s, deadband 0, 10m

These are written for new installs only: an upgrade never changes an existing config file. An install whose config file has no retention and no max_size keeps its history until the disk is critically full. The server says so in its log at every start, as a warning: historian has no disk budget: historian.retention is unlimited and historian.max_size is 0, ..., followed by what then happens (the oldest days purged, logging paused, or the disk filling up) and the keys to set. The free-space alarms and the pause on a critically full disk apply to every install.

  1. Open System health in the Studio. The PC resources and historian storage section shows:
    • the CPU of the machine and of the server, memory, and every disk the server writes to (historian, export, audit trail, logs), with its free space;
    • the historian’s size, its growth per day, and the days left until the disk is full at that pace;
    • the size of the columnar store’s file, the retention, the last purge and the scheduled export.
  2. The History cards at the bottom trend CPU, memory, the historian disk’s free space and the historian’s size over the range you pick.

Most of the volume usually comes from a few tags logged far more often than needed. Every tag without a historian logging rule is logged on each update the tag engine passes on. With a deadband of 0, that is every driver poll, even when the value does not change. A tag polled 20 times a second writes about 1.7 million points per day.

Find the tags with the most points. The history is in the columnar store (no CSV partitions are written next to it), so count them with the read-only historian query (scada_query_historian, see SQL queries), for example since a given time (Unix nanoseconds):

SELECT tag_path, count(*) AS points
FROM tag_history
WHERE timestamp >= 1762732800000000000
GROUP BY tag_path ORDER BY points DESC LIMIT 20

In a build without the embedded database, look at the largest folders under data/historian/year=YYYY/month=MM/day=DD/ instead (one tag= folder per tag). Then, for those tags:

  • give them a deadband in their driver mapping, or a historian logging rule (ON_CHANGE with a deadband, or PERIODIC at the rate you really need);
  • or set the default policy for tags without a rule (step 3).

In the historian section of config.yaml:

historian:
logging: # tags without a historian logging rule
default_min_interval: 1s # at most one point per second; the latest value of a change is kept
default_deadband: 0 # 0: log changes only, never repeated identical values
default_max_interval: 10m # a steady value still gets a point every 10 minutes

A quality change is always logged at once. Tags with a rule keep their rule.

default_max_interval logs a steady tag’s current value once per interval even when no update arrives: at 10m, at most 144 points per tag per day for a tag that never changes. Count it in the budget for sites with many steady tags; 0 turns it off. A rule can have its own heartbeat, max_interval_s: see A rule’s heartbeat.

historian:
retention: 90d # whole days older than this are deleted
retention_overrides: # optional, per tag or path pattern; the most specific wins
- "Utilities/Energy/*=400d"
- "Lab/Batch/*=unlimited"
  • The purge runs every hour (purge_interval). It deletes whole UTC days, from the columnar store and from any CSV history written before it, together.
  • It never deletes today or yesterday, nor the two newest days that hold data, even with a short retention or a wrong clock.
  • A pattern is an exact tag path, Area/Line/* (everything below Area/Line), or a pattern whose * matches inside one level (*/Temperature).
  • Every purge is written to the audit trail: action HISTORIAN_PURGE, the days, the number of tags, the bytes and rows deleted, and the reason.

To see what the retention would delete now, without deleting anything, open GET /api/historian/storage as a Lead_Engineer or Administrator. The retention_preview lists each day and tag.

5. Set the budget and the free-space lines

Section titled “5. Set the budget and the free-space lines”
historian:
max_size: 50GB # 1 GB = 1024 MB; 0 = no budget
disk:
warn_free: 15% # "Disk space low" alarm
critical_free: 5%, 5GB # the larger of the two applies
purge_on_critical: true
pause_on_critical: true
quota_target: 90% # an over-budget purge goes down to 90% of max_size

What happens:

State machineThe levels of the historian's disk guard
The levels of the historian's disk guardThe historian logs normally while the free space is above warn_free; over max_size it purges its oldest days down to quota_target. Under warn_free it raises Disk space low. Under critical_free it raises Disk space critical and, with purge_on_critical, purges its oldest days until the free space is halfway back to the warning line. If the disk is still under critical_free, with pause_on_critical, it stops writing history and keeps recent values in memory only; it resumes by itself when the free space is 20% above the critical line.Loggingfree over warn_freeDisk space lowsystem alarm, mediumDisk space criticalalarm, high; purgesthe oldest daysLogging pausedalarm, critical; recentvalues in memory only;tag values, alarms andcommands go onover max_size: oldest dayspurged to quota_targetfree underwarn_freeover againundercritical_freepurge freesenoughstill criticalfree 20% over the criticalline: resumes by itself
Only history writing stops on a critically full disk: tag values, alarms and commands go on.
Read as text

The historian logs normally while the free space is above warn_free; over max_size it purges its oldest days down to quota_target. Under warn_free it raises Disk space low. Under critical_free it raises Disk space critical and, with purge_on_critical, purges its oldest days until the free space is halfway back to the warning line. If the disk is still under critical_free, with pause_on_critical, it stops writing history and keeps recent values in memory only; it resumes by itself when the free space is 20% above the critical line.

States

  • Logging (state): free over warn_free
  • Disk space low (state): system alarm, medium
  • Disk space critical (state): alarm, high; purges the oldest days
  • Logging paused (state): alarm, critical; recent values in memory only; tag values, alarms and commands go on

Transitions

  • Start → Logging (transition)
  • Logging → Logging (transition): over max_size: oldest days purged to quota_target. At any level. Recorded as HISTORIAN_PURGE, with the alarm Historian purged its oldest history; never today or yesterday. A purge that did not lower the size is tried again an hour later.
  • Logging → Disk space low (transition): free under warn_free
  • Disk space low → Logging (transition): over again
  • Disk space low → Disk space critical (transition): under critical_free
  • Disk space critical → Disk space low (transition): purge frees enough. With purge_on_critical the oldest days are deleted until the free space is halfway back to the warning line.
  • Disk space critical → Logging paused (transition): still critical. With pause_on_critical, when the free space is still under critical_free after the purge. HISTORIAN_LOGGING_PAUSED. Points are kept in memory for the trends, not in the spool.
  • Logging paused → Disk space low (transition): free 20% over the critical line: resumes by itself. HISTORIAN_LOGGING_RESUMED, with the number of points that were not stored.
Situation What the historian does
Free space under warn_free on any disk the server writes to System alarm Disk space low on the SCADA server (medium).
Historian over max_size Deletes its oldest days, all tags, down to quota_target. Raises Historian purged its oldest history and audits the purge.
Free space under critical_free System alarm Disk space critical (high). With purge_on_critical, the oldest days are deleted, never today or yesterday. CSV partitions of older CSV history go first, until free space is halfway back to the warning line. In the columnar store, the oldest days go only until the store has room inside its file for about two days of new history (at least 64 MB). See Disk space critical with the columnar store below.
Still under critical_free With pause_on_critical, stops writing history: Historian logging paused (critical). Recent values stay in memory for trends. Tag values, alarms and commands are not affected.
Free space back 20% above the critical line Resumes by itself, and audits HISTORIAN_LOGGING_RESUMED with the number of points that were not stored.

The columnar store’s file does not shrink when rows are deleted. The freed space inside it is reused by new history, so the file stops growing. The budget counts what is in use (System Health shows both figures). A purge never deletes today or yesterday.

Disk space critical with the columnar store. Deleting rows from the columnar store frees no disk space: it makes room inside the store’s file, which new history fills before the file grows. So the purge on a critically full disk never deletes as much as the disk is short of. It deletes the oldest days only until the store has room inside its file for twice its daily ingest (the largest of the last three complete days, at least 64 MB), and only when that room has fallen under half of it. The file then stops growing; it does not shrink.

  • The purge is audited as HISTORIAN_PURGE with the reason disk_critical. Its text gives the free space, the shortfall against the critical line and the room it aims for, and says that it frees no disk space.
  • When the store holds less than the shortfall, the audit record and the server log also say that something other than the historian is filling the disk. Find what it is: deleting history will not bring the space back.
  • A purge that frees no room inside the store (a small store whose rows share one block) waits an hour before the next attempt, so it never goes on through the whole history.
  • The pause counts the store’s free blocks as room for history, as long as the volume itself keeps at least half the critical line free (the store’s write-ahead log and its checkpoint write to the disk). The pause message then gives both figures, for example “(… with the columnar store’s free blocks)”.

Size max_size to the disk. With the columnar store, the nightly snapshot keeps two copies of it beside it (step 7b), so leave about three times max_size free on the historian’s disk.

Leave room for the spool. When the columnar store does not take writes, new points wait in the spool folder (data/historian/spool/) until it takes them again, up to historian.spool.max_size (2 GB by default); past it, new points are counted lost. The spool is not part of max_size: count up to historian.spool.max_size on the historian’s disk beside the budget. While logging is paused on a critically full disk (pause_on_critical), points are kept in memory only, not in the spool, so the spool never writes below the critical line. The spool

historian:
spool:
max_size: 2GB # the default
historian:
store:
memory_limit: 1GB
threads: 2
path_index: false
  • memory_limit and threads keep the store from taking most of the machine’s memory and every core when a large query runs. The values are applied to the store when it opens. Without memory_limit the store takes 25% of the machine’s memory, at least 512 MiB and at most 4 GiB; without threads, one thread per 64 MiB of the cap, at most every core. Past its cap the store spills to scada_history.duckdb.tmp next to its file: leave room for it on the historian’s disk. Memory caps of the stores
  • path_index: false removes the store’s index on tag and time. On this data it took about 50 bytes per point, against about 5 bytes for the data itself, and trend queries are no faster with it. Removing it frees that space for new history. The file does not shrink: to get the disk space back, move the file away while the server is stopped. It is recreated empty: the history it held is no longer read (no CSV copy of it is written), only CSV history from before the columnar store is.

7. Export closed days to Parquet every night

Section titled “7. Export closed days to Parquet every night”

In Pro and Enterprise, with a store without encryption at rest, the daily export is on by default: a config file without enabled exports, and without keep_days it keeps the historian’s retention. Set the keys only to change that:

historian:
export:
schedule: "02:00" # local time
dir: "./data/historian_export"
format: parquet # parquet (Pro, Enterprise) or csv
keep_days: 30 # exported days kept in dir; without it: the historian's retention
compress: true
  • Each closed UTC day becomes dir/year=YYYY/month=MM/day=DD/data.parquet, with the columns timestamp, tag_path, value and quality.
  • A day is exported once. _export_manifest.json in dir records it, and a run never writes a day again unless forced: POST /api/historian/export/scheduled with {"force": true, "day": "YYYY-MM-DD"}.
  • dir must be inside historian.export_allowed_dirs (by default the server’s data folder).
  • Plan the disk for it. The export takes about 10 bytes per stored point. A day is skipped when its disk has less free space than the day’s estimated size plus the disk guard’s critical line (critical_free, not warn_free): Scheduled historian export failed (ALM-SYS-HISTORIAN-EXPORT, low) says why, and the next run tries again. The export also refuses a destination on a critically full disk; every failure is audited.
  • The first run exports every closed day of the history: about 18 s per day of history at 1,000 tags/s on a workstation, so about 30 minutes for 90 days.
  • An encrypted historian is never exported to plain files by the schedule; its second copy is the nightly snapshot.
  • To keep the export off, see Keep the export off: an old generated section with enabled: false left exactly as written turns it on.

Copy the exported folders to your long-term storage. The historian’s retention can then stay short.

Every edition with the columnar store copies it every night at 01:30 to ./data/backup/historian, and keeps 2 copies, each about the size of the store. The new copy is written and verified before the oldest is deleted, so count up to three times the columnar store’s size on that disk, or point historian.snapshot.dir at another disk. A snapshot is skipped (older ones are kept) only when its disk has less free space than its estimated size plus the disk guard’s critical line (critical_free; earlier releases used warn_free), with the message “…plus the disk guard’s critical margin of X”. A skip raises Nightly historian snapshot failed or skipped (ALM-SYS-HISTORIAN-BACKUP, medium); it is retried hourly. The nightly snapshot

health:
interval: 10s
cpu_high_percent: 90 # CPU high, sustained ...
cpu_high_for: 10m # ... for this long
memory_low_percent: 10 # available memory under 10% ...
memory_low_for: 1m # ... for a minute
  1. Restart the server. The log shows historian disk budget with the values in force.
  2. Open System health. Check the retention, the budget and the disk lines.
  3. The first purge runs about 30 seconds after the start. Then open Security > Operations audit and filter on HISTORIAN_PURGE.

The historian keeps the history you chose, stays under its budget, and warns before the disk is full. If the disk still fills up, it stops writing history instead of failing, and starts again by itself. The system alarms appear with every other alarm and can be acknowledged. Their condition tags are System/Resources/<name>.

  • The disk keeps filling although retention is set. Look at the growth per day in System Health and at the largest tag= folders: a few tags logged on every poll usually explain it (step 2).
  • The columnar store’s file is still large after a purge. That is expected (step 6). Its free space is reused before it grows again.
  • Nothing was purged. GET /api/historian/storage shows protected_from: days from that date on are kept. With a single day of history, nothing is purged.
  • The disk stays critically full after a purge. With the columnar store that is expected: the purge makes room inside the store’s file, not on the disk. If the purge record says that something other than the historian is filling the disk, free that space; the historian is not the cause.
  • retention or max_size seemed to be ignored. Earlier releases stopped reading the historian: keys that came after a sub-section the server does not read (such as the sample files’ parquet_export:). They are read now: after the upgrade, check the historian disk budget line in the log, because a retention or budget that was silently ignored before now applies, and the first purge can delete days.
  • An unreadable max_size (for example 20 G) is logged as a warning, “unreadable historian.max_size ignored”, and the historian runs with no size budget. Write it like 20GB.
  • Free space looked wrong on a Linux network filesystem. The byte thresholds (critical_free: 5%, 5GB) now use the filesystem’s fragment size; earlier releases could read a wrong free space where its block size was larger. The percentages were right.
  • “export folder … is not allowed”. Add the folder to historian.export_allowed_dirs.