Historian Basics: Every Failure Is a Lost Timestamp, Value, or Quality Flag
A historian stores three fields per sample, not one. Why a trend goes flat during the event you are investigating, OPC UA Part 4 StatusCode and DataChangeFilter, and the storage number to run before you start.
I was chasing a batch excursion. An operator said the reactor temperature spiked, and the quality data pointed at the same minute. I opened the historian trend on that window. Forty minutes of flat line. One point at 601 °C, then 605 °C forty minutes later, nothing between them. The historian had not lost the data. I had told it that 4 °C was not a change: that node's deadband was percent 1, its EURange was 0 to 600, so the real band was 6 °C.
What gets stored is not one number
Start a historian design at "which tags should I collect" and you walk into the trap above again. One sample is three fields.
| Field | What it is | Where it is defined |
|---|---|---|
| timestamp | When the value was valid — not when it was written | OPC UA Part 6 DateTime: 100-nanosecond intervals since 1601-01-01 UTC |
| value | The number itself | Width comes from the tag's data type |
| quality | Whether you may trust that number | OPC UA Part 4 StatusCode, 32 bits |
Almost every historian failure in the field is one of those three being discarded or overwritten. The forty flat minutes were the value.
A StatusCode carries severity in its top two bits: Good 0x00000000, Uncertain 0x40000000, Bad 0x80000000, mask 0xC0000000. The remaining bits are the diagnosis. Bad_NoCommunication (0x80310000) means the link is down. Uncertain_LastUsableValue (0x40900000) means the server is handing you a stale sample it knows is stale. Collapse both into the word "bad" and you have thrown away the bits that told you where to look.
Quality is the field people drop
My position on this is not subtle: the quality column in a historian table should be a 32-bit integer, not a boolean. I still regularly see a single REAL column with the quality discarded at the driver. Then the last value before a comm drop sits there looking like an ordinary measurement, and every average over that window is quietly wrong.
OPC UA Part 13 defines the aggregate functions — TimeAverage, Minimum, Maximum, Count, Interpolative and the rest. A client asking for TimeAverage over a stretch containing bad-quality samples is supposed to get a quality flag back with the result, not a clean-looking number. If you never stored the quality, there is nothing to build that flag from.
A flat Good line and a flat Uncertain_LastUsableValue line look identical on screen and mean opposite things. Bad-quality gaps and interpolation and handling tag quality codes cover that.
Run the storage number before you start
Get the arithmetic out before you fix a tag count and a rate. Take 16 bytes a sample — 8 for the timestamp, 4 for a float value, 4 for the StatusCode — and store 10,000 tags at 1 Hz:
160,000 B/s = 160 kB/s
13.82 GB/day
5.05 TB/year
That is raw ingest, before compression and before indexes. One line gets you your own figure:
awk -v tags=10000 -v hz=1 -v bytes=16 'BEGIN{
b=tags*hz*bytes
printf "%.0f B/s %.2f GB/day %.2f TB/year\n", b, b*86400/1e9, b*86400*365/1e12
}'
If 5 TB is not affordable you have two levers: fewer tags, or a slower rate — and a deadband is the second lever. This number is what decides periodic versus exception sampling and where you draw the line on retention and downsampling.
Set the deadband per tag, not per project
The setting that produced those forty minutes was a percent deadband. In the OPC UA Part 4 DataChangeFilter, DeadbandType is None (0), Absolute (1), or Percent (2). Percent is defined against the node's EURange Property from Part 8, Data Access, and the server computes DeadbandValue / 100 * (EURange.high - EURange.low). So the same "1%" is one unit on a 0 to 100 range and six units on 0 to 600 — identical config, six times coarser.
I reach for Absolute (1) first. It is in the same engineering units as the value, so there is nothing to convert and nothing to worry about when a node inherited the wrong EURange from a template. Percent goes only on tags whose EURange I have read with my own eyes. The full criteria are in setting OPC UA deadbands and deadband and compression field notes.
How the timestamp goes wrong
Of the three fields, the timestamp fails most quietly. A server clock two seconds out puts the alarm time and the trend cursor in different places, and overlaying two systems' trends can invert cause and effect. Clock drift, trend cursor alignment and late data after a network outage are three different symptoms of it.
Discrete tags carry one extra switch: the Stepped flag in the historical configuration of OPC UA Part 11, Historical Access. Get it wrong and the server itself puts a slope through a history read and returns intermediate values that never existed. It is one boolean.
Regulated records follow different rules
Data you keep because an engineer wants to trend it and data you keep because a contract or a regulator says so can share a table without sharing a rulebook. Under 21 CFR Part 11 or an equivalent regime, §11.10(e) requires secure, computer-generated, time-stamped audit trails. Downsampling or recalculating those records is not a decision you make by yourself. The procedure for editing a value by hand is in manual data correction and audit.
Next thing to check
Open a trend now and find a flat stretch. Read that node's DeadbandType and EURange first, then the StatusCode on the samples in that window. If both are Good and the deadband is small, that is when you start suspecting the network. And if a tag rename is anywhere on your plan, read rename migration before you do it — data stored under the old name does not move to the new one.