Troubleshooting
Why a Node-RED timestamp creates a new InfluxDB tag
Short answer
Your timestamp is landing in the tag set, and InfluxDB line protocol gives every distinct tag value its own series, so each sample is written as a separate one-point series and the trend is blank. Put the epoch time in the point's time slot with the node's time precision set to match, and keep tags to identifiers that repeat, such as machine and sensor.
On this page
- Why does every timestamp create a new tag in InfluxDB?
- What four parts make up an InfluxDB point?
- How do I check where the timestamp lands?
- What payload format does the InfluxDB out node expect?
- How do I map Machine1/Sensors/Vibration to a clean layout?
- How do I move the timestamp to the point time slot?
- What should the bucket and Grafana show after the fix?
- Questions asked
Your timestamp is ending up in the tag set, and InfluxDB treats every distinct tag value as a separate series, so each sample lands in its own one-point series and the trend shows nothing usable. Swapping the time for a constant string "fixes" the chart only because the tag value stops changing. The rest of the path — MQTT broker, write token, bucket, Grafana link — is already proven, so leave it alone. Below is where the time belongs in an InfluxDB 2.0 point, the debug check that confirms the fault, the topic mapping that gives you Machine1/Sensors/Vibration as a clean layout, and the function node that writes it.
Why does every timestamp create a new tag in InfluxDB? #
Because the timestamp is being sent as a tag value: every distinct tag value forms its own series, so a time that changes on each write gives each sample a private one-point series, and no trend can be drawn until the time moves to the point's time slot.
Tags are the indexed identifiers of a point, and a series is one unique combination of measurement and tag values. An epoch number never repeats, so every write invents a new combination. Illustrative example: a sensor publishing one sample per second creates 1 sample/s × 3,600 s/h = 3,600 new series in an hour and 3,600 × 24 h = 86,400 in a day, where the correct layout holds exactly one series for that sensor for as long as it runs. Twice the sample rate, or a second sensor writing the same way, doubles that growth.
That is also why your constant string worked: the tag collapsed to a single value, every sample joined one series, and the line reappeared. The decision is fixed — the time goes to the point's time slot, and tags carry only identifiers that repeat across samples, such as machine and sensor.
What four parts make up an InfluxDB point? #
A point has four slots in a fixed order — measurement, tags, fields, then one timestamp — and line protocol, the text format every write is reduced to, keeps them apart: tags are indexed identifiers, fields are the measured numbers, and time stands alone.
| Part | Role | Rule |
|---|---|---|
| Measurement | Groups related series, for example Sensors |
Small, fixed set |
| Tags | Indexed identifiers such as machine and sensor |
Values must repeat; each unique combination is one series |
| Fields | The measured values, for example value |
Change with every sample; not indexed |
| Timestamp | The point's time slot | Its own slot — never a tag, never a field |
The write node builds this line from your message, so the slot a value occupies in msg.payload decides where it lands in the bucket. Everything here is scoped to the bucket-based write path of InfluxDB 2.x and the 2.x output node of the node-red-contrib-influxdb package; confirm the accepted shapes in the help sidebar of your installed version.
How do I check where the timestamp lands? #
Wire a debug node set to show the complete message object directly before the output node, deploy, publish one MQTT message, and read which object of the payload holds the epoch number.
Three outcomes, three decisions:
- The epoch number sits in the second object of a two-object array. It is being written as a tag, one new series per sample. This is the fault in this article — go to the fix.
- The epoch number sits in the first object. It is a field, and Grafana draws it as a data line near 1,700,000,000,000 instead of placing points along the time axis. Same fix: move it to the time slot.
- No timestamp appears and still nothing arrives. The payload shape is the suspect; the next two sections cover it. When not even the write shows up, start from troubleshooting missing data in a Node-RED, InfluxDB and Grafana stack.
A confirming sign in the bucket's Data Explorer: a tag dropdown listing hundreds of values that all look like epoch times.
What payload format does the InfluxDB out node expect? #
The single-point output node accepts a few shapes — a plain value, one object of fields, a two-object array of fields then tags, or an array of point objects — and the payload must match one of them exactly, with numbers sent as numbers.
Payload in msg.payload |
What the node writes |
|---|---|
| A number or a string | One field named value under the measurement configured on the node |
One object, for example { value: 4.7 } |
Each key becomes a field |
| An array of two objects, fields then tags | First object is the fields, second is the tags |
| An array of point objects | One point per element, each with its own measurement, fields, tags and time |
The usual reasons a reading shows up as "value isn't there" or "nothing received":
- The two objects arrive in the wrong order, so the tags are read as fields.
- The measurement is empty on both the node configuration and
msg.measurement. - The reading arrives as a string, for example
"4.7"straight from the MQTT payload, and is stored as a string field that will not plot. Convert it withNumber(). - A change node set to move the payload somewhere else removes it before the output node reads it. Copy the value, or set the new payload in the function node instead.
Decision: make the debug output match one row of the table exactly, numbers converted, before you look anywhere else.
How do I map Machine1/Sensors/Vibration to a clean layout? #
Split the MQTT topic once and give each level a fixed slot: level one is the machine tag, level two is the measurement, level three is the sensor tag, and the payload contributes only the reading.
| Topic level | InfluxDB slot | Example |
|---|---|---|
| 1 | Tag machine |
Machine1 |
| 2 | Measurement | Sensors |
| 3 | Tag sensor |
Vibration, Debit |
| Payload | Field value |
the reading itself |
This yields one measurement, two low-cardinality tags and one field. A new machine or a new sensor adds a tag value and needs no schema change, and Grafana filters then read naturally: measurement Sensors, sensor equal to Vibration, field value.
How do I move the timestamp to the point time slot? #
Put a function node between your MQTT and change nodes and the output node, and build the two-object payload there: the epoch time goes in the fields object under the time key its help documents, and only machine and sensor go in the tags object.
- Place the function node on the wire, with the debug node still after it.
- Build the payload as below. The point-time key is
timeon the 2.x output node; confirm it in the help sidebar of your installed version.
// p: an array of strings from one MQTT topic;
// 'Machine1/Sensors/Vibration' becomes ['Machine1', 'Sensors', 'Vibration']
const p = msg.topic.split('/');
// msg.payload: the reading as it arrives, for example the string '4.7'
msg.measurement = p[1]; // 'Sensors'
msg.payload = [
{ value: Number(msg.payload), time: Date.now() }, // fields, time in ms
{ machine: p[0], sensor: p[2] } // tags
];
return msg;
- Set the node's time precision to milliseconds, because
Date.now()returns an integer count of milliseconds since the epoch; the precision and the unit of the number must agree or the point lands at the wrong instant. - If the sensor has no usable clock, leave the
timekey out and the bucket stamps the point as it arrives. If the flows run in a container, confirm the time source first, since Node-RED in Docker uses the host clock, not its own time andDate.now()inherits whatever the host says. - Deploy and publish one test message per sensor.
The debug node after the function is the test that proves it: exactly two objects — fields holding value 4.7 and a time such as 1754000000000, an example epoch-milliseconds value — then tags holding machine set to Machine1 and sensor set to Vibration. Three objects, a string value, or the time in the second object means an upstream change node still reshapes the message.
What should the bucket and Grafana show after the fix? #
In the bucket's Data Explorer the measurement Sensors should hold one series per machine and sensor pair — two series for Vibration and Debit on one machine — and the sensor tag should list only sensor names, no epoch-looking values.
- Series count steady. Two sensors stay two series however long the flow runs, instead of the 86,400-a-day growth the tag timestamp produced.
- Tag dropdowns clean. Epoch numbers still listed mean an old flow still writes the broken shape; find that path and stop it.
- History checked after the fix. The old one-point series remain until you delete them or retention ages them out, so verify against a time range after the fix, or write the test into a fresh bucket.
- Time axis correct. Points sit at publication time, or at the device time you sent, and Grafana draws Vibration and Debit as two continuous lines with the filters set above.
Decisions by case:
- Time as a tag or as a field: move it to the time slot with the function node above.
- No time sent: let the server stamp the point and skip the precision step.
- Reading arrives as a string: convert with
Number()before the write. - Points at the wrong instant: set the time precision to the unit of the number you send.
One boundary to keep: this stack is monitoring and history, so interlocks, trips and machine safety stay on the PLC, never on a dashboard query.
Questions asked
What happens when the node's time precision disagrees with the unit I send?
The point is stored at the wrong instant, so the panel looks empty for the current range. If the precision is nanoseconds while you send a Date.now() value in milliseconds, 1,700,000,000,000 is read as nanoseconds: 1,700,000,000,000 ns divided by 1,000,000,000 equals 1,700 s after the epoch, so the point lands in January 1970. A nanosecond value read as milliseconds lands thousands of years ahead. Set the node's time precision to the unit you send.
Does every point need a timestamp?
No. In line protocol the timestamp is optional: when a point arrives without one, InfluxDB stamps it with the server's own UTC time at nanosecond resolution. That is the right choice for a sensor or PLC with no reliable clock, and it removes any clock skew between Node-RED and the database. Add an explicit time only when the sampling instant matters more than the write instant.
Can several points go to InfluxDB in one message?
Yes, with the batch output node. In the node-red-contrib-influxdb package that node sends a list of points together in one batch, and its payload format differs slightly from the single-point output node, so read the accepted shapes in its help sidebar for your installed version before building the array. Use it when you gather readings over an interval and want one write instead of many.