Explainer
InfluxDB tag and field schema for a PLC historian dashboard
Short answer
Store each PLC signal's identity in a tag, its reading in one field named value, and split the signal types into measurements such as temperature, pressure, flow and alarms, writing binary states only when they change. At a 1.5-second cycle a 130-signal line produces about 86.7 samples per second, so long raw windows are what slow a dashboard: a 30-second mean bucket cuts a ten-signal full-window read from about 288,000 points to 14,400.
On this page
- What schema should PLC data use in InfluxDB?
- What belongs in a tag and what belongs in a field?
- How much series cardinality does a 130-signal PLC line create?
- How many rows does a twelve-hour dashboard window return?
- How do you keep long time windows fast in Grafana?
- How do you write this schema from Node-RED?
- How do you prove the redesign worked before you trust it?
- Questions asked
Put each PLC signal's identity in an InfluxDB tag, its changing reading in one field named value, and split the signal types into measurements such as temperature, pressure, flow and alarms. That layout gives Grafana an indexed path to each signal, keeps the series count near one series per signal, and moves the work of a long time window from the dashboard to a database-side aggregate. The sections below place every value in that layout, work the row arithmetic for a 130-signal line sampled on a 1.5-second cycle, and give the Node-RED point structure plus the checks that prove the dashboard stays fast.
What schema should PLC data use in InfluxDB? #
Put each signal's identity in a tag, its changing reading in one field named value, and split the signals into measurements by category — temperature, pressure, flow — with alarms and on-off states in their own measurements recorded only when the state changes. In InfluxDB 1.8 terms, the measurement separates what kind of signal it is, the tag set identifies which signal it is, and the field carries the reading. One point then holds exactly one signal's value, and a query prunes signals by indexed tag values instead of discovering them from field keys.
| Layer | Example | What it decides |
|---|---|---|
| Measurement | temperature, pressure, flow, pumps, valves, alarms, on_off | Which category a dashboard reads |
| Tag key | CT for temperature, CP for pressure, CF for flow, misc_mes elsewhere | The identity dimension of that category |
| Tag value | CT_310 | The stable position code of one signal |
| Field key | value | The same field name in every point |
| Field value | for example 72.4, a number | The reading at that timestamp |
A wide point — every signal as its own field key in one payload — is not wrong on its own, and it suits a fixed field set that is always read together. It suits a signal-selection dashboard badly, because the dashboard must discover signals from field keys and pull each one out; the article on extracting single InfluxDB fields from Node-RED for a dashboard chart shows what that costs.
Alarms and on-off states keep the same shape with a boolean field value, which takes their write volume from every cycle down to a handful of events per shift. This logging exists for dashboards and post-mortems: the alarm handling an operator acts on, and every interlock, stays in the PLC and SCADA layer, never in the historian.
What belongs in a tag and what belongs in a field? #
A tag carries a stable identity you select or group by, such as the tag key CT holding the position code CT_310; the field named value carries the number that changes. Putting the changing reading itself into a tag multiplies the series count by every value the sensor reports.
InfluxDB indexes tag values and not field values, so a filter on a tag prunes the data before it is read, while a condition on a field has to visit the values. The reading of a transmitter changes on every cycle: as a tag, each new reading would be a new tag value, a new series and a new index entry — unbounded growth with no selection benefit. The position code never changes, so it indexes once per signal and prunes cleanly at every zoom level.
Descriptions need the same discipline. A tag value containing free text is an identity: reword it and the signal starts writing into a new series while the old data stays behind the old name. Make the tag value the position code alone, and keep the human-readable description in the dashboard's variable mapping, where an edit costs nothing.
A series is one measurement plus one complete tag-value set. Cardinality grows with the distinct combinations actually written — never automatically with each tag key — but two independently varying tags multiply each other, which is why this layout carries exactly one identity tag per point.
How much series cardinality does a 130-signal PLC line create? #
One analog signal with one stable identity tag lands as exactly one series, so a 130-signal line settles at about 130 series across its category measurements — a few hundred once spares are counted — far inside what InfluxDB 1.8 handles comfortably on a small edge server.
Cardinality trouble comes from what a tag contains, not from how many tags exist. A tag whose values change over time — a reading, a batch counter, a timestamp in disguise — adds a series for every distinct value, and two such tags multiply. Servers run out of memory on designs built that way; a fixed position code does not behave like that.
Set the design target at one series per signal. After the backfill, run the InfluxQL statement that returns the series count for the database: a count above the signal count means a tag value is changing, and that tag moves to a field before the index grows on its own. The host under that index is the same class of machine as the one sized in the article on sizing a self-hosted Node-RED InfluxDB Grafana historian, with the database, the flows and the dashboards on one box.
How many rows does a twelve-hour dashboard window return? #
At the example line's 1.5-second cycle, a raw twelve-hour read of ten signals returns about 288,000 points — 43,200 seconds divided by 1.5 seconds is 28,800 per signal, times 10 signals — and that returned-row count, not the tag design, is what a slow panel is choking on.
Grafana's Query inspector reports what a panel actually requested and received, and it keeps two numbers apart: a returned row can be a raw point or a time bucket, and the query decides which. Confirmed writes say nothing about this path — ingestion health and query health are separate checks.
| Window | Samples per signal | Rows for ten signals |
|---|---|---|
| 30 minutes | 1,200 | 12,000 |
| 3 hours | 7,200 | 72,000 |
| 12 hours | 28,800 | 288,000 |
The arithmetic: twelve hours is 43,200 seconds, and 43,200 s ÷ 1.5 s = 28,800 samples per signal, so 28,800 × 10 signals = 288,000 rows. Thirty minutes is 1,800 s ÷ 1.5 s = 1,200; three hours is 10,800 s ÷ 1.5 s = 7,200. Every figure assumes uninterrupted sampling with no aggregation and no missed cycles — the potential raw volume, not a measured result. Across the whole line, 130 signals at that cadence produce about 86.7 samples per second (130 ÷ 1.5).
You can produce every number in that table before touching the database — the same exercise the guide on calculating rows returned by SQL queries walks through for query results — and the number that decides the redraw is the one the Query inspector reports afterwards.
How do you keep long time windows fast in Grafana? #
Aggregate in the query, not in the browser: a 30-second mean bucket collapses the same twelve-hour, ten-signal read to 14,400 returned rows — 1,440 per signal, one per pixel column on a panel about 1,440 pixels wide — a twentyfold cut against the raw read.
Put the mean into the query itself: the database averages value into 30-second buckets and ships one row per bucket, so the network, the browser and the panel all work on 14,400 rows instead of the raw volume. For the full window: 43,200 seconds ÷ 30 s = 1,440 buckets per signal, and 1,440 × 10 signals = 14,400 rows, while 288,000 ÷ 14,400 = 20, so the panel handles one twentieth of the raw read. Let the window drive the bucket: Grafana derives an interval from the time range and the panel's data-point limit, so a four-hour view uses wider buckets than the full window and the returned-row count stays near the panel's pixel count at every zoom level.
Keep raw reads for short windows only: as a working rule, hold a raw query under about ten thousand returned rows — at one sample per signal per cycle, that is 1,000 samples per signal, or 1,500 seconds, roughly 25 minutes — and hand anything longer to the bucketed mean. Rows also scale with pen count, and a panel carrying every signal in one view defeats the aggregation; the article on how many trend pens fit in one historian client window sets that budget.
How do you write this schema from Node-RED? #
In Node-RED, write with the batch output node of the InfluxDB node package: it sends a list of points, each naming the measurement, carrying the identity in tags as strings and the reading in fields — a number for analog signals, a boolean for states.
The InfluxDB package in the palette provides that batch output node (influx batch), which sends a list of points to the database in one request. Two example points in the layout above:
[
{ "measurement": "temperature",
"tags": { "CT": "CT_310" },
"fields": { "value": 72.4 } },
{ "measurement": "pressure",
"tags": { "CP": "CP_117" },
"fields": { "value": 4.6 } }
]
Tag values are strings, the analog field value is a number, and alarm and on-off points use the same field with true or false; CP_117 is an example position code in the same pattern as CT_310. Generate the list from the PLC tag list with a short script rather than typing every point by hand. Batching cuts request overhead, not data volume — the same samples reach the database either way. If a function node sets the point time itself, check what actually lands: a timestamp handled in the wrong shape arrives as a new tag rather than a new time, which the article on why a Node-RED timestamp creates a new InfluxDB tag traces.
How do you prove the redesign worked before you trust it? #
Prove it in three checks: a round-trip test point per measurement, a series count that matches the signal count, and a Query inspector read on the heaviest panel whose returned rows track the bucket count as the window stretches.
-
Write one point per measurement with a known value and a known time, query it back, and require an exact match on tag, value and timestamp — a mismatch is a type, name or write-path fault, and it is cheaper to meet it here than in a panel.
-
Run the series-count statement before and after the backfill: one identity tag per point should land the count at about one series per signal, and a count above the signal count names a tag whose values are changing — move it to a field.
-
Open the heaviest panel and stretch the window from half an hour to the full window while reading the Query inspector: with the 30-second buckets, the full-window read should report about 14,400 rows — if it reports raw-scale tens of thousands, the panel query is bypassing the aggregate.
-
Keep the paths apart when something still misbehaves: confirmed writes say samples arrive, the Query inspector says what a read costs, and the draw time says what the browser adds. A dashboard that slows only as the window grows is a read-volume problem, not a connection fault.
The decision: tag the identity, field the reading, split the categories, aggregate long windows and keep raw reads short — on this arithmetic, a full-window panel drops from about 288,000 rows to 14,400 and draws in seconds.
Questions asked
How much disk does this schema cost compared with the wide layout?
Not materially. The layout decides which rows are selected and returned; each row's size comes from the value, the timestamp and the repeated tag metadata, and short, stable tag values such as a position code compress well. If disk is the binding constraint, size by points per day times bytes per point rather than by tag count.
What happens to old data when a tag value has to change?
A tag value is part of the series identity, so renaming a position code starts a new series and the history stays under the old name. Queries that span the change need both values, or the old series has to be rewritten. Treat position codes as permanent, and put friendly names that may change in the dashboard mapping instead.
Should points carry the PLC timestamp or the arrival time?
Use the PLC timestamp when process causality or backfill matters, because arrival time shifts with network and queueing delays on the way through the flow. Use arrival time only when the write path itself is under test. Whichever you choose, set it deliberately in the writer and keep one precision, or points land out of order or collapse onto the same second.
How do Grafana variable dropdowns work with this layout?
Directly, and that is the point of the tag: a variable lists the tag values of a measurement, and the panel query filters on the selected value, so the dropdown builds from indexed metadata with no field-listing detour. With identity buried in field keys, every dropdown needs a field query per category — the resource-intensive path this layout removes.
Does the same layout apply to newer InfluxDB versions?
The separation travels — stable identity in a tag, the reading in a field, categories as separate measurements or buckets — but names, interfaces and cardinality handling differ between versions, so check the exact statements and limits against the release you deploy. The layout and arithmetic in this article are written for InfluxDB 1.8.