Skip to content
On this page

Services

Historian

The Factory+ historian role, which records device data from Sparkplug or the UNS with the context needed to find it again.

7 min read Edit this page
Central services
ACS implementationACS IngestSee how the AMRC Connectivity Stack implements this.View on GitHub

A historian is the Factory+ component that subscribes to device data and records every value.

MQTT keeps no history, and a value that a device publishes is gone once every subscriber has received it. A historian keeps that value available for analysis, reporting and training models long after it was published.

Factory+ defines the historian as a role, not as a service with its own interface. Because the right storage depends on the site and the data, a historian MAY use any time-series database, file format or other store. Factory+ does define what a historian reads, what it records with each value and which permissions it needs, and that is what lets any historian produce history that the Factory+ read interfaces can serve.

A historian has no HTTP interface of its own and registers no service in the Directory. Clients read recorded data through two interfaces, and an implementation serves both from what its historians record. Data Access serves datasets of history. i3X is the Factory+ northbound interface.

graph LR
  EA[Edge Agents] -->|"Sparkplug"| MQTT[MQTT broker]
  MQTT -->|"spBv1.0/#"| SH[Sparkplug historian]
  MQTT -->|"spBv1.0/#"| UI[UNS ingester]
  UI -->|"UNS/v1/..."| MQTT
  MQTT -->|"UNS/v1/#"| UH[UNS historian]
  SH --> Store[("Store of the site's choice")]
  UH --> Store
  Store --> DA[Data Access]
  Store --> I3X[i3X]
  SH -.->|"rebirth requests"| CE[Command Escalation]

Kinds of historian

Factory+ device data reaches the broker in two forms, and there is a kind of historian for each. An installation MAY run either or both.

  • A Sparkplug historian subscribes to the Sparkplug namespace and records device data from births and DATA messages. It sees every Factory+ device, including devices with no place in the ISA-95 hierarchy. It records each value under the device’s UUID and Sparkplug address.
  • A UNS historian subscribes to the Unified Namespace and records its JSON messages. It sees only devices that have an ISA-95 placement. It records each value under the device’s place in the plant as well as its UUID.

Sparkplug historian

A Sparkplug historian MUST subscribe to spBv1.0/#, or to the part of the Sparkplug namespace it is responsible for. It MUST handle each message as follows.

Births and session state

Sparkplug DATA messages are meaningless without the birth that came before them, because they usually carry only an alias for each metric.

The historian MUST keep the most recent NBIRTH and DBIRTH for each address. It MUST use the birth to resolve each DATA metric’s alias to its name, datatype and properties. If a Node publishes a new NBIRTH or an NDEATH, the historian MUST forget the births of that Node’s devices, because Sparkplug requires those devices to be born again.

The historian MUST read Factory+ context from a birth only when the birth carries the Factory+ birth marker. It MAY record values from births without the marker, with the address as their only context.

Asking for a missing birth

A historian can start, or reconnect to the broker, while devices are already publishing. It then receives DATA for devices whose births it has not seen, and it cannot record those values.

In that case the historian SHOULD ask the device to rebirth by setting Device Control/Rebirth through Command Escalation, as described in Requesting a rebirth. It SHOULD ask the device rather than its Node, because a Node rebirth makes every device on the Node publish its birth again. The historian SHOULD rate-limit its rebirth requests for the same device.

What it records

The historian records the metrics of device births (DBIRTH) and device data (DDATA), one record for each metric value. It MAY also record Node metrics.

The historian MUST NOT record:

  • a value of a metric that is transient, either in its birth or in the DATA message that carries it. A transient metric is one the publisher does not want historised.
  • a value whose DATA message gives a datatype different from the birth’s, or that is not valid for its datatype. Recording it would store a value of the wrong type under the metric.

The historian SHOULD NOT record null values. In Sparkplug a null value means the value is unknown, not that the metric has a value.

The historian MAY leave out datatypes it cannot store, such as DataSets, Templates, property sets and arrays. If it does, it SHOULD log that it has left them out, because otherwise nobody can find the gap in the record.

The time of each record is the metric’s timestamp, or the payload’s timestamp when the metric has none, or the time the message arrived when neither has one. The historian MUST convert timestamps with the Factory+ timestamp rule. The rule reads values below 1015 as milliseconds and all others as nanoseconds.

Context it keeps

A value is only useful if a reader can tell which device it came from and what it means, even after the device has moved to another address or its configuration has changed. The historian works out this context from the birth by the rules in Schema and instance UUIDs, and stores it with each value.

ContextSourceRequirement
Device UUIDThe birth’s top-level Instance_UUIDMUST
Metric nameThe metric’s full name from the birthMUST
DatatypeThe metric’s Sparkplug datatype from the birthMUST
Time and valueThe metricMUST
Device schemaThe birth’s top-level Schema_UUIDSHOULD
Bottom-level instance and schemaThe deepest object that contains the metricSHOULD
Instance and schema chainEvery object that contains the metric, from the top downSHOULD
UnitThe metric’s engUnit property from the birthSHOULD
Sparkplug addressThe group ID, Node ID and device ID of the messageSHOULD
Simulation markersThe metric’s simulated and run_id propertiesSHOULD, when present

The historian SHOULD store values so that a reader can find all of a device’s history by its device UUID, whatever address the device published from. It SHOULD also let a reader find all values of the objects that follow a given schema, by schema UUID.

UNS historian

A UNS historian MUST subscribe to UNS/v1/#, or to the part of the UNS it is responsible for.

A UNS message is self-contained, because its topic and MQTT v5 user properties carry the context that a Sparkplug historian has to work out from a birth. The UNS historian therefore keeps no session state.

  • It MUST record one record for each sample in a message. The samples are the message’s own value and timestamp and each entry of its batch. A batch entry with no timestamp takes the message’s timestamp.
  • It MUST use the Type user property, not the JSON type of the value, to decide how to store each value. The UNS page requires this of every consumer.
  • It SHOULD NOT record a sample whose value is null.
  • It decides for itself whether to record metrics whose Transient property is "true".

The UNS historian keeps this context with each value:

ContextSourceRequirement
Device UUIDThe InstanceUUID user propertyMUST
MetricThe topic segments after Edge and the device IDMUST
DatatypeThe Type user propertyMUST
Time and valueThe sampleMUST
ISA-95 levelsThe topic segments between UNS/v1 and EdgeSHOULD
Device schemaThe SchemaUUID user propertySHOULD
Instance and schema chainThe InstanceUUIDPath and SchemaUUIDPath user propertiesSHOULD
UnitThe Unit user propertySHOULD
Simulation markersThe Simulated and RunId user propertiesSHOULD, when present

Storage

Factory+ does not prescribe how a historian stores data, how long it keeps it or how it compresses it. Two consequences of the data model are worth planning for in any store.

  • If a historian keys its series by unit as well as by metric, it starts a new series when a metric’s unit string changes. A site that renames a unit then splits that metric’s history. The engineering units page explains how to avoid this.
  • A device that moves to a new Sparkplug address keeps its device UUID. A store keyed by UUID keeps one history for the device, and a store keyed only by address does not.

Permissions

A historian signs in as its own principal and needs grants to read the data it records.

A Sparkplug historian needs the Warehouse composite permission, granted with the wildcard target, because it reads every device and can ask any device to rebirth.

Composite permissionWarehouse
6958c812-fbe2-4e6c-b997-6f850b89f679
Everything a Sparkplug historian needs: Read whole Sparkplug namespace and Rebirth.

The Warehouse composite permission contains these two permissions:

PermissionUUIDWhy the historian needs it
Read whole Sparkplug namespace81833dbb-1150-4078-b1db-978c646ba73eTo subscribe to spBv1.0/# on the MQTT broker.
Rebirthfbb9c25d-386d-4966-a325-f16471d9f7beTo ask devices for their births through Command Escalation.

A UNS historian needs Read entire UNS, granted with the wildcard target. UNS messages need no birth, so it needs no Rebirth permission.

PermissionRead entire UNS
ffa40b36-3a61-4545-832a-2d1e8b860d63
Subscribe to and read every topic under UNS/v1/#.

A historian that records only part of the namespace MAY instead hold narrower permissions that cover only that part.

Esc