Troubleshooting
Why a Grafana MSSQL dashboard shows no data from Node-RED
Short answer
If the Node-RED flow still inserts, a blank Grafana MSSQL panel is a read-path fault, not a collection fault. Read the newest row in MSSQL first: current rows there move the fault to the Grafana data source, its read-only login, the query fields or the timestamp convention. Fix the layer whose boundary check fails first.
On this page
- Read the newest row in MSSQL first
- Match the panel symptom to the failing layer
- Test the data source connection before building panels
- Prove the query before styling the panel
- Worked example: a naive local timestamp against a last 1 hour panel
- Trace one timestamp through the stack
- Fix and verify end to end
- Questions asked
If Node-RED is still inserting sensor readings and log data into MSSQL, a Grafana panel built on that database that shows no data is a read-path fault, not a collection fault. One query settles it: read the newest stored timestamp directly in the database. A current newest row moves the fault to the Grafana data source, its read-only login, the query fields or the timestamp convention, and rebuilding the Node-RED flow fixes none of those. A stale newest row keeps you on the write side. Below are the boundary checks in order, a symptom-to-layer table, and a worked example of the most common silent fault in this stack: a local-time timestamp judged against a UTC panel range.
Read the newest row in MSSQL first #
Run this against the same database and table the dashboard queries, before you touch Grafana. Grafana cannot render rows that never reached the database, so this one check splits the stack in two:
- Select the newest row from the insert table, ordering by the timestamp column descending.
- Compare that stamp with the source system's clock, not with your workstation's.
- Wait a minute or two and confirm that newer rows keep arriving.
- Open a handful of recent rows and look for null timestamps, text where a number belongs, and duplicate stamps that would smear a trace.
If the newest stamp is current, leave the Node-RED side untouched and go to the data source checks. If it is stale or frozen, stop at the write path: the flow's state, the database node's error output, network reachability to the instance, the SQL service itself and the write login's permissions. A write path that dies quietly after a network interruption is a documented fault pattern of its own — the same signature is dissected in why Node-RED InfluxDB writes fail after a network outage.
The two sides have separate jobs: Node-RED acquires and stores, Grafana queries and renders. A successful insert proves the first path only.
Match the panel symptom to the failing layer #
Take one reading at each boundary: the newest row in MSSQL, the data source connection test, the query result in the panel editor, and the rendered panel. The boundary where a reading first goes wrong names the layer to fix.
| Panel symptom | Layer that owns the fault |
|---|---|
| Connection or authentication error | Data source host, instance, database, login or network path |
| Query error | SQL, table or column choice, data types, missing read permission |
| Connection test passes, panel shows no data | Panel time range excludes the rows, timestamp conversion, or no current rows in that database |
| Only old values on screen | Writes stopped, or range and refresh behavior hide newer rows |
| Points at the wrong times | UTC and local-time handling across write, storage, query and display |
| Gaps or doubled points | Dropped or replayed inserts, null values, duplicate timestamps |
A blank panel by itself is not evidence that collection failed.
Test the data source connection before building panels #
Grafana's built-in Microsoft SQL Server data source connects straight to your instance with no additional tools and no cloud hop, which suits a customer portal that must stay on-premises. Configure and test it on the Grafana host: a server name that resolves from your workstation may not resolve from the machine running Grafana.
- Enter the host and instance reachable from the Grafana host, and select the database that receives the Node-RED inserts.
- Use a dedicated SQL login with read rights on exactly the objects the panels query.
- Check name resolution and the SQL Server port from the Grafana host — 1433 on a default instance, while named instances often listen elsewhere.
- Click Save & test at the bottom of the data source configuration, and record the exact returned error if it fails.
Classify the failure. An authentication error points at the login and its permissions. A transport error points at routing, the firewall or name resolution. Success moves you on to query shape and time handling. If the test passes but every panel is still blank, add Grafana's Datasource tests - MSSQL dashboard, three panels fed from a test database, to confirm the data source renders anything before you debug your own SQL.
One rule holds across all of this: do not give the dashboard login write access to make a read error disappear. It corrects nothing that a wrong host, database or query caused, and it widens what a compromised dashboard session could do to production history.
Prove the query before styling the panel #
Start with a few recent rows from one known sensor or log stream, unfiltered. In the panel editor, check four things: the query returns rows at all; the timestamp field comes back as a time type, not display text; the value field is numeric if the panel draws a series; the result is ordered by time. Only then apply the panel's time range, and add line, machine or event filters one at a time.
SELECT TOP (20) ts, value
FROM line1_log -- example table and column names
ORDER BY ts DESC;
Here ts is the datetime column and value the numeric reading — example names; substitute your insert table and its timestamp column. If the raw query returns rows but the time-filtered one returns none, jump to the timestamp convention below. If the raw query returns text, switch the panel to a table or convert at the database side.
Bound every operational panel by time and by the assets it actually shows. An unbounded query makes SQL Server chew the whole history on every refresh, and every dashboard sharing the instance competes for the same capacity; the arithmetic of that is laid out in how dashboard capacity depends on active query load.
Worked example: a naive local timestamp against a last 1 hour panel #
The numbers below are an illustrative case for this stack, chosen because the thread's setup writes plant data from the plant clock; they are not measurements from your plant.
Inputs: the insert column is a datetime that carries no UTC offset, and Node-RED fills it from the plant clock; the plant runs at UTC+02:00 (Central European summer time — substitute your own offset); the newest row was written at 12:00 UTC and stored as the naive stamp 14:00; the panel shows the last 1 hour, ending at now, 12:00 UTC.
Rule: the query's time filter compares the stored stamps against two UTC instants, the range start and the range end. A naive stamp carries no offset, so the comparison is shifted by the whole difference between the plant clock and UTC.
Arithmetic: the stamp Grafana sees for the newest row is 14:00; the window runs from 11:00 to 12:00 UTC; the error is 14:00 minus 12:00, or plus 2 h, exactly the plant's offset. Every stamp written in the last 2 h lands after the window's end and is excluded. If the table is young — logging began at 11:30 UTC, stored as 13:30 — every stamp lies past the window, and the panel reports no data with a perfectly healthy write path.
Result: the panel hides the newest 2 h of rows, or everything the table contains.
Decision: read the newest stamp as UTC and compare it with the range end. If it is newer, the column is naive local time; fix it at one boundary — store UTC or an offset-aware type going forward, and convert once in the query. Do not patch each panel with a fixed 2 h shift: when daylight saving ends the offset becomes plus 1 h, and the patch turns a 2 h error into a minus 1 h error.
Trace one timestamp through the stack #
When connectivity and query pass but points sit at wrong times, read the same logical row at each stage and find where the shift first appears: the event time handed to Node-RED; the value stored in the column, and whether that type carries an offset; the raw time the query returns in the panel editor; the rendered point against the dashboard's timezone setting.
The stage where the offset first appears names the fix. If it appears at insert, correct the write mapping — stamp in UTC or in an offset-aware type. If the stored value is right but the query result is shifted, convert at that single query boundary. If only the render is shifted, it is the panel or dashboard timezone setting, not the data.
Historians mis-stamp in a cousin way: backdated data rewritten with the current clock has the same root cause — whichever clock writes the stamp owns the timeline. That variant is covered in why a historian shows current time for backdated PLC data.
Fix and verify end to end #
Let the branch that failed define the correction. No current rows: restore the inserts and watch several successive records land before returning to Grafana. Failing connection test: correct the host, database, login or network path. Failing query: correct the fields and types. Rows outside the range: align the timestamp convention at one boundary.
Then verify with a new known event: change a sensor reading or write a log entry, and watch that row arrive inside the panel range within one refresh. Reload the dashboard in the customer portal context and confirm the dashboard account cannot modify the database.
The same one-reading-per-boundary method, applied to the InfluxDB variant of this stack, is laid out in troubleshooting missing data in a Node-RED InfluxDB Grafana stack.
Questions asked
Can the Node-RED, MSSQL and Grafana stack run entirely on-premises?
Yes. Grafana's built-in Microsoft SQL Server data source connects directly to the instance with no additional tools, so collection, storage and dashboards all stay inside the plant network. Keep the SQL Server port closed to anything outside that network and publish the dashboards through the local portal only.
Which Grafana control actually tests the MSSQL connection?
Save & test, at the bottom of the Microsoft SQL Server data source configuration. Grafana's getting-started guide also ships a Datasource tests - MSSQL dashboard with three panels driven from a test database, so you can confirm the data source renders data before debugging your own queries.
Why do plotted points sit hours ahead of the real event?
The timestamp column holds plant local time with no offset, while the query compares it against a range anchored to UTC, so every point shifts by the UTC offset. Store UTC or an offset-aware timestamp type, and convert once at the query; a fixed hour patch breaks at the daylight-saving change.
Should the Grafana login be able to write to MSSQL?
No. Give the dashboard a dedicated SQL login with read rights on exactly the tables and views its panels query. Write access does not fix a wrong host, database or query; it only widens what a compromised dashboard session could do to production history. One login per consumer keeps the SQL audit trail attributable.
The query returns rows in the panel editor but the panel still shows nothing. What next?
The editor result is unfiltered; the panel adds its time range on top. Compare the newest stored stamp with the range end: a stamp newer than the end means the range excludes it and the timestamp convention is wrong; stamps older than the window mean writes have stopped or refresh does not match the insert rate.