Skip to content

How to Monitor Factory Machines in Real Time with MQTT and a Self-Hosted Dashboard

Poll Modbus TCP data from PLCs with Node-RED, store it in InfluxDB, and visualise it in Grafana. Expose the dashboard to remote users with a Localtonet tunnel.

Summary in your language
In this article 13 sections
🏭 IIoT · Modbus · MQTT · Node-RED · InfluxDB 2.x · Grafana · 2026

Build a measured, read-only telemetry path from factory equipment to an authenticated remote dashboard

This guide polls an authorized Modbus endpoint with Node-RED and publishes validated telemetry through a loopback-bound Mosquitto broker. Telegraf stores that telemetry in InfluxDB 2.x, and Grafana visualizes it. It covers installation on Debian or Ubuntu, credential setup for every component, local verification, and remote HTTPS access to Grafana through a Localtonet HTTP tunnel without opening inbound router ports. The result is a near-real-time monitoring system. Its latency depends on polling, buffering, database writes, queries, and dashboard refresh intervals. It is not a deterministic control, interlock, emergency-stop, or safety system.

🔒 Read-only monitoring with least-privilege credentials 📊 Self-hosted MQTT, InfluxDB 2.x, and Grafana 🌐 HTTPS remote access to Grafana only, with optional SSO

What this monitoring system can and cannot do

Factory PLC data flowing through MQTT and InfluxDB to a Grafana dashboard and remote browser.
The monitoring path polls PLC registers, publishes MQTT messages, stores time-series data, and presents it in Grafana.

The objective is to collect operational measurements without placing browser users, databases, or public-facing services on the machine network. Node-RED reads selected Modbus data, converts raw register values into explicit engineering values, and publishes telemetry to MQTT. Telegraf consumes those messages and writes them to InfluxDB. Grafana queries the stored series and presents them to authorized viewers.

Calling this architecture "real time" without qualification would be misleading. If a PLC is polled every two seconds, Telegraf flushes every ten seconds, and Grafana refreshes periodically, the displayed value can be several stages behind the physical process. Network retries, broker queues, database load, query time, clock error, and browser refresh behavior can increase that delay. Measure actual source-to-screen latency under normal and degraded conditions instead of assuming a fixed result.

Monitoring is not control or functional safety

Do not use this stack to implement machine control, safety interlocks, emergency stops, protective trips, or any function whose delayed or missing execution could injure people or damage equipment. Keep certified control and safety functions in their approved systems. Changes to an operational technology environment require authorization from the asset owner and must follow the site's engineering, cybersecurity, safety, and change-management procedures.

This guide deliberately uses a read-only acquisition path. It does not include Modbus writes, remote setpoint changes, PLC programming, or Node-RED control outputs. If an organization later considers a write path, treat it as a separate engineering project with a formal risk assessment, independent authorization, fail-safe behavior, testing, and audit controls.

This guide targets InfluxDB 2.x

The storage layer, the Telegraf influxdb_v2 output, the influx CLI commands, and every Flux query in this article are written for InfluxDB 2.x. InfluxDB 3 does not support Flux. If you deploy InfluxDB 3, Grafana must query it with SQL or InfluxQL, and database creation, token management, and data-source configuration follow a different procedure that this article does not cover.

Architecture and trust boundaries

Monitoring architecture with private PLC services and a tunnel exposing only Grafana.
PLC polling and data services stay private while the Localtonet path terminates at Grafana.

A production deployment should place the acquisition gateway in an OT DMZ or another segmented network zone approved by the site. The gateway needs only the minimum connectivity required for five tasks: reading the approved Modbus devices, communicating with its local services, obtaining time and name resolution from approved infrastructure, retrieving controlled updates, and establishing the Localtonet client's outbound connection.

🏭 OT data source An authorized PLC, meter, drive, or protocol gateway exposes only the measurements approved for monitoring. Where the device supports such controls, limit access to the required read function codes, unit IDs, addresses, and source hosts.
🔄 Acquisition and validation Node-RED polls Modbus and validates response length and quality. It decodes the documented data representation, applies scaling, adds identity and source timestamps, and publishes a normalized MQTT event.
📨 Private message transport Mosquitto listens on loopback when all producers and consumers run on the same gateway. MQTT access-control rules restrict separate publisher and subscriber accounts.
🗄️ Storage and visualization Telegraf parses MQTT payloads into a deliberate measurement, tag, and field schema. InfluxDB 2.x stores the time series. Grafana queries it with Flux and evaluates dashboard or alert conditions.
🌐 Outbound remote-access path The Localtonet client establishes an outbound connection to a Localtonet relay server. An HTTP tunnel exposes Grafana through an assigned HTTPS address without inbound router port forwarding or a public IP address.
🔐 Remote identity controls Localtonet SSO can place a sign-in page in front of the HTTP tunnel before any request reaches Grafana. Keep Grafana authentication enabled as a separate layer, and give remote users only the access they need.
Connection Direction Recommended restriction
Gateway to Modbus endpoint Gateway initiates toward the approved OT device Permit only required hosts, ports, unit IDs, read operations, and polling rates.
Node-RED to Mosquitto Local publisher connection Bind the broker to loopback and grant the account write access only to telemetry topics.
Telegraf to Mosquitto Local subscriber connection Grant read access only to the required telemetry topic tree.
Telegraf to InfluxDB Local database write Use a token that can write only to the intended bucket.
Grafana to InfluxDB Local database query Use a separate read-only token rather than reusing Telegraf's write credential.
Localtonet client to relay Outbound from the gateway Allow the client only through approved outbound firewall and proxy policy.
Remote browser to Grafana HTTPS through the Localtonet tunnel Turn on HTTPS-only, require SSO or another tunnel access control, and retain Grafana authentication.

Do not expose Mosquitto, Node-RED, InfluxDB, the PLC interface, or gateway management services through public tunnels. In this design, the Grafana HTTP service is the only Localtonet tunnel target. Administrative access should use a separately approved management path.

Prerequisites and tested-environment record

You need all of the following before installing anything:

  • A currently supported Debian or Ubuntu release with systemd, on a CPU architecture that every component publishes packages for. Check with dpkg --print-architecture (for example amd64 or arm64).
  • An account with sudo rights on the gateway and an approved maintenance window.
  • Outbound HTTPS access from the gateway to the package sources used below: your distribution mirrors, repos.influxdata.com, apt.grafana.com, and GitHub for the Node-RED installer script. If the site uses a package proxy or internal mirror, configure it first.
  • An authorized Modbus TCP endpoint, or an appropriate serial integration method, with explicit permission for read-only polling.
  • The vendor register map, including address notation, data type, scaling, units, byte order, word order, unit ID, and supported function codes.
  • Network reachability from the gateway to the approved Modbus endpoint, without giving remote viewers direct OT-network access.
  • Approved DNS and NTP or another reliable time-synchronization source. timedatectl should report the clock as synchronized.
  • Disk capacity sized from measured ingestion and retention behavior, plus space for logs, package updates, temporary files, backups, and database maintenance.
  • A Localtonet account. The Localtonet client must be installed on the gateway and connected with its AuthToken before you create the tunnel. Follow the Quick start in our documentation for the client installation on your platform. The dashboard, broker, and database remain self-hosted, but the remote path depends on the Localtonet account, the connected client, and our relay service.
  • A password manager or secret store for the credentials you will create: two MQTT accounts, a Node-RED editor login, an InfluxDB administrator, two InfluxDB tokens, and a Grafana administrator. Do not reuse a common factory password.
  • A backup destination outside the gateway's primary disk and a documented restore test.
Record the tested baseline before deployment

Document the Debian or Ubuntu release, CPU architecture, Node.js and npm versions, Mosquitto version, Node-RED version, Modbus node version, Telegraf version, InfluxDB version (2.x), Grafana version, Localtonet client version, repository URLs, signing-key fingerprints, and test date. Pin or otherwise control upgrades according to site policy. The commands in this guide follow the vendors' published Debian/Ubuntu procedures, but vendors rotate signing keys and change installer options, so recheck the key fingerprints and Node.js requirements at installation time.

Measure capacity instead of estimating from a device label

A gateway cannot be sized from RAM capacity or device count alone. Polling frequency, registers per request, response latency, number of devices, JSON size, MQTT delivery behavior, Telegraf batching, field cardinality, dashboard queries, retention, storage media, and backup activity all affect performance.

Begin with a representative pilot. Measure CPU, memory, disk write rate, database growth, I/O latency, MQTT queue behavior, Modbus timeout rate, and dashboard query duration during normal operation and a credible peak. Extrapolate storage from measured bytes written per day and apply the intended retention period. Add backup and operational headroom, then validate the estimate with a sustained load test. Avoid unsupported claims about how many PLCs a particular Raspberry Pi or industrial PC can handle.

Install the components on Debian or Ubuntu

This section installs every package and brings each service under systemd. Component-specific configuration (broker accounts, InfluxDB tokens, Telegraf input and output, Grafana settings) follows in later sections, so do not open any service to the network while you work. Start by refreshing the package index and installing the tools the repository steps need:

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg wget apt-transport-https
sudo mkdir -p /etc/apt/keyrings

Mosquitto

Debian and Ubuntu ship Mosquitto in their standard repositories, which is the simplest supported path. The Eclipse Mosquitto project also publishes its own Debian repository and an Ubuntu PPA if you need a newer release than your distribution provides.

sudo apt-get install -y mosquitto mosquitto-clients
sudo systemctl enable mosquitto
sudo systemctl status mosquitto

Debian packages normally start the service immediately after installation. With Mosquitto 2.x and no listener configured, the broker accepts only local connections, so it is safe to leave running until you apply the configuration in the MQTT section. The packaged /etc/mosquitto/mosquitto.conf includes every *.conf file in /etc/mosquitto/conf.d/. You will add your settings there rather than editing the main file.

Node-RED with the official Debian install script

The Node-RED project publishes an install script for Debian-based systems, including Ubuntu and Raspberry Pi OS. It installs a supported Node.js release (replacing an older one if necessary), installs Node-RED globally, and creates the nodered.service systemd unit. It also adds the helper commands node-red-start, node-red-stop, and node-red-log. Run it as the non-root user that should own the Node-RED user directory, not as root:

bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered-deb)

The script asks for confirmation before it changes Node.js. Read the prompts rather than piping a blind "yes", because replacing Node.js can affect other software on the gateway. Recent versions of the script also offer to run the initial settings wizard. You can accept it or configure settings.js manually as shown below. When it finishes, enable the service so it survives a reboot, then start it:

sudo systemctl enable nodered.service
sudo systemctl start nodered.service
systemctl status nodered.service
node-red-log    # follows the service log; press Ctrl+C to exit

The service runs Node-RED as the user who ran the script, with the user directory at ~/.node-red. If you cannot use the script, the alternative documented path is installing a supported Node.js release yourself and running sudo npm install -g --unsafe-perm node-red. That path does not create a systemd unit. Node-RED's linux-installers repository publishes the reference nodered.service file that the script installs, so review it, set the User and paths for your system, and install it under /etc/systemd/system/. Do not rely on a process started from an interactive terminal.

Secure the Node-RED editor before building flows

By default the Node-RED editor has no login and listens on all interfaces on port 1880. Close both gaps before you enter any credentials into flows. First, generate a bcrypt hash for the editor password. The command prompts for the password, so it does not land in shell history:

node-red admin hash-pw

Then edit ~/.node-red/settings.js. Inside the exported settings object, set uiHost so the editor listens only on loopback, uncomment and fill in adminAuth with the hash you generated, and set a credentialSecret so that credentials stored in flows are encrypted with a key you control:

module.exports = {
    // ...existing settings...

    uiHost: "127.0.0.1",

    adminAuth: {
        type: "credentials",
        users: [{
            username: "flowadmin",
            password: "PASTE_THE_BCRYPT_HASH_FROM_HASH_PW",
            permissions: "*"
        }]
    },

    credentialSecret: "REPLACE_WITH_A_LONG_RANDOM_VALUE_FROM_YOUR_SECRET_STORE",

    // ...existing settings...
};

Restart the service with sudo systemctl restart nodered.service and confirm with ss -ltnp | grep 1880 that the listener shows 127.0.0.1:1880. To use the editor from a management workstation, use an approved path such as an SSH port forward (ssh -L 1880:127.0.0.1:1880 user@gateway), not a public tunnel. Restrict settings.js to its owner with chmod 600 ~/.node-red/settings.js, because it now contains the credential secret.

Install the Modbus nodes

This guide uses node-red-contrib-modbus, the Modbus node collection maintained in the BiancoRoyal/node-red-contrib-modbus repository. It provides a shared client configuration node for Modbus TCP or serial connections plus read-only nodes such as Modbus Read and Modbus Getter. It also includes write and server nodes, which this read-only design does not use. Install it through the editor (Menu, Manage palette, Install, search for the package name) or from the command line in the Node-RED user directory:

cd ~/.node-red
npm install node-red-contrib-modbus
sudo systemctl restart nodered.service

Check the package's compatibility notes against your installed Node-RED and Node.js versions, and record the installed version in the baseline. If you use a local USB-to-RS485 adapter, the Node-RED service user needs access to the serial device. On Debian and Ubuntu this usually means adding it to the dialout group with sudo usermod -aG dialout <node-red-user> and restarting the service.

InfluxDB 2.x and Telegraf from the InfluxData repository

InfluxData publishes both InfluxDB 2.x and Telegraf in one signed APT repository. Download the archive key, verify it against the SHA-256 checksum published on InfluxData's install page, and only then convert it into a keyring. InfluxData has rotated this key before, so copy the checksum from the vendor page at installation time instead of trusting a value reproduced in an article:

curl --silent --location -O https://repos.influxdata.com/influxdata-archive.key
echo "<SHA256_PUBLISHED_BY_INFLUXDATA>  influxdata-archive.key" | sha256sum --check -
cat influxdata-archive.key | gpg --dearmor | sudo tee /etc/apt/keyrings/influxdata-archive.gpg > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main" | sudo tee /etc/apt/sources.list.d/influxdata.list
sudo apt-get update
sudo apt-get install -y influxdb2 influxdb2-cli telegraf

If sha256sum --check does not print OK, stop and investigate before adding the repository. The influxdb2 package installs the server as the influxdb systemd service, and influxdb2-cli provides the influx command. By default InfluxDB 2.x listens on port 8086 on all interfaces. Because only local services need it, bind it to loopback in /etc/influxdb/config.toml:

http-bind-address = "127.0.0.1:8086"
sudo systemctl enable influxdb
sudo systemctl restart influxdb
systemctl status influxdb
ss -ltnp | grep 8086

Do not start Telegraf yet. Its packaged sample configuration usually enables system metric inputs and a legacy [[outputs.influxdb]] output that does not match an InfluxDB 2.x setup with tokens. Leave the service stopped until the pipeline section, where you configure it and test it first:

sudo systemctl stop telegraf
sudo systemctl enable telegraf

Grafana from the Grafana Labs repository

Grafana Labs publishes a signed APT repository for Grafana OSS. Add the key and repository, install the package, and enable the grafana-server service:

wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt-get update
sudo apt-get install -y grafana
sudo systemctl daemon-reload
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
systemctl status grafana-server

Before you log in for the first time, bind Grafana to loopback. Open /etc/grafana/grafana.ini, find the [server] section, and set:

[server]
http_addr = 127.0.0.1
http_port = 3000

Restart with sudo systemctl restart grafana-server. The Localtonet client reaches Grafana on 127.0.0.1:3000, so remote access does not require Grafana to listen on the LAN. You will set domain and root_url after the tunnel exists and you know its host name.

Verify signatures and keep repositories under change control

Each repository above is trusted only for packages signed by its key, through the signed-by option. Do not import vendor keys into a global trusted keyring, do not disable signature checks to work around errors, and record each key fingerprint (gpg --show-keys /etc/apt/keyrings/<file>.gpg) in the change record.

Understand the Modbus data before building the flow

Modbus register data decoded by address, type, byte order, scale, and unit.
Register addressing, data type, byte order, scaling, and units must match the PLC documentation.

Modbus registers are 16-bit storage locations at the protocol level, but that does not mean every value is an unsigned 16-bit integer. A device can encode a signed integer in one register or combine two registers into a 32-bit integer or IEEE 754 floating-point number. It can also combine four registers into a 64-bit value, use bit fields, or apply a vendor-defined representation. Multi-register values also require the correct word order and byte order.

Register-map detail Why it matters Required action
Address notation A manual may label the first holding register as 40001 while a client expects offset 0. Confirm whether the Node-RED node expects a zero-based protocol offset or the vendor's reference notation.
Function code Holding registers (FC 3) and input registers (FC 4) use different read functions. Select the documented read type rather than inferring it from the numeric address.
Unit ID A TCP endpoint may route requests to one of several downstream devices. Use the unit ID specified for the exact device and route.
Signedness and width The same 16 bits produce different values when interpreted as signed or unsigned. Decode the documented type and combine the documented number of registers.
Word and byte order Two-register integers and floats can be swapped into several possible orders. Validate decoding against a known value or the vendor's diagnostic tool.
Scale and engineering unit A raw value might represent tenths, hundredths, or a nonlinear conversion. Apply only the vendor-documented scale and preserve the unit in the schema or dashboard.
Invalid-value sentinel Devices may reserve values for sensor failure, under-range, or unavailable data. Reject or mark invalid values instead of graphing them as genuine measurements.

Polling also creates load. Group contiguous values only when the device supports the requested range. Set realistic connection and response timeouts, avoid overlapping requests, and add backoff after repeated failures. Log Modbus exception codes and timeouts with the device identity and requested address range. A communication failure should produce an explicit stale or unavailable state, not a fabricated zero.

Modbus RTU integration choices

A protocol-converting Modbus RTU-to-TCP gateway accepts Modbus TCP requests and generates corresponding RTU transactions on an RS-485 network. A transparent serial device server transports serial bytes over a network but may not perform Modbus TCP protocol conversion. A USB-to-RS485 adapter only gives the local gateway a physical serial interface. It does not, by itself, expose a Modbus TCP server.

Choose the Node-RED connection method that matches the actual hardware. In node-red-contrib-modbus, the client configuration node selects TCP or serial. A protocol gateway is addressed as Modbus TCP. A local USB adapter requires the serial client type with the correct device path (for example a stable /dev/serial/by-id/ link), baud rate, parity, stop bits, unit address, RS-485 wiring, and the serial-port permissions described in the installation section. Do not treat these three integration methods as interchangeable.

Design and secure the MQTT layer

Use a predictable topic hierarchy that identifies the source without embedding secrets or uncontrolled user input. One suitable pattern is:

factory/<site>/<line>/<machine>/telemetry

Keep high-cardinality details such as event IDs in payload fields rather than creating an unbounded number of topics. Define topic ownership, payload schema, units, timestamp format, quality indicators, and compatibility rules before connecting multiple machines.

Write the broker configuration

Because every MQTT client in this design runs on the gateway, bind Mosquitto to loopback so port 1883 is not reachable from the LAN, and disable anonymous access. Create /etc/mosquitto/conf.d/factory.conf:

listener 1883 127.0.0.1
allow_anonymous false
password_file /etc/mosquitto/passwd
acl_file /etc/mosquitto/acl

Then create /etc/mosquitto/acl with one block per account:

user nodered_pub
topic write factory/+/+/+/telemetry

user telegraf_sub
topic read factory/+/+/+/telemetry

Validate wildcard behavior against the topic structure you actually deploy. Each + matches exactly one level, so a topic with an extra level will be denied. That is the intended least-privilege behavior.

Create the two accounts with mosquitto_passwd

mosquitto_passwd prompts twice for each password when you do not pass one as an argument, which keeps passwords out of process listings and shell history. The -c flag creates a new file and overwrites any existing one, so use it only for the first account:

sudo mosquitto_passwd -c /etc/mosquitto/passwd nodered_pub
sudo mosquitto_passwd /etc/mosquitto/passwd telegraf_sub

The file stores salted password hashes, not plain passwords, but it should still be readable only by the broker. Restrict both files to the broker account:

sudo chown mosquitto:mosquitto /etc/mosquitto/passwd /etc/mosquitto/acl
sudo chmod 0700 /etc/mosquitto/passwd /etc/mosquitto/acl

Recent Mosquitto 2.x releases log a warning at startup when the password or ACL file is world-readable or owned by an unexpected account, and state that future versions will refuse such files. If you see that warning after restarting, adjust ownership to match the account your packaged service runs as, rather than loosening permissions.

Test and restart the broker

Mosquitto does not provide a dedicated syntax-check-only flag. Validation means restarting the service and confirming it came back cleanly with the new listener. Do this in the maintenance window:

sudo systemctl restart mosquitto
systemctl status mosquitto
sudo journalctl -u mosquitto -n 50 --no-pager
sudo tail -n 50 /var/log/mosquitto/mosquitto.log
ss -ltnp | grep 1883

The Debian package configures Mosquitto to log to /var/log/mosquitto/mosquitto.log, so configuration errors may appear there rather than in the journal. The ss output must show 127.0.0.1:1883 only. If the service fails to start, the log line usually names the offending option and file.

Keep secrets out of commands, flow exports, and screenshots

Do not pass MQTT or InfluxDB passwords directly on a shell command line. Command arguments can be visible to other processes and can remain in shell history. Use protected environment files, the component's own encrypted credential storage, or a supported secret store. Remove credentials before exporting Node-RED flows or sharing diagnostic bundles.

Choose QoS and retained-message behavior deliberately

MQTT QoS 0 provides best-effort delivery and can lose messages during a disconnect. QoS 1 provides at-least-once delivery, which improves delivery assurance but permits duplicates, so the consumer and storage path must tolerate repeated events. QoS 2 adds protocol overhead. Select it only after confirming that its guarantees and costs match the requirement.

A retained telemetry message lets a newly connected subscriber receive the most recently published value immediately. That is convenient, but the value may be old. Include a source timestamp and quality state, and configure dashboards to mark data stale after a defined interval. If retained messages are used, decide in advance how they are cleared when a machine is decommissioned or a topic changes.

MQTT persistence and queue limits determine what happens during a consumer outage. Node-RED, Mosquitto, Telegraf, and InfluxDB do not automatically form an unlimited lossless pipeline. Document the expected behavior for broker restart, subscriber disconnect, database outage, full disk, and gateway reboot. If telemetry must survive those events, test the selected persistence and queue settings under realistic outage durations.

Build the Node-RED, MQTT, Telegraf, and InfluxDB pipeline

With the editor reachable only through your management path, build the acquisition flow. In Node-RED, MQTT broker credentials entered in the MQTT broker configuration node are stored in the separate encrypted credentials file, protected by the credentialSecret you set earlier, and are not included in normal flow exports.

1

Configure one authorized Modbus read

Add a Modbus Read node and create its client configuration with the approved endpoint, port or serial interface, and unit ID. Set the read function, zero-based start address, quantity, polling interval, and timeout. Begin with a small request and confirm it against the vendor register map before expanding the flow.

2

Validate and decode the response

Check that the response contains the expected register count. Decode signedness, width, byte order, and word order exactly as documented. Reject Modbus exceptions, incomplete responses, impossible values, and device-specific invalid sentinels. Use the node's built-in help panel to confirm the output message shape for your installed version.

3

Normalize the telemetry event

Apply documented scaling and create stable field names. Add site, line, and machine identifiers, an RFC 3339 timestamp, and a quality field. Distinguish a source timestamp from a gateway receipt timestamp if both are available.

4

Publish with the least-privilege MQTT account

Add an MQTT out node with a broker configuration pointing to 127.0.0.1 port 1883 and the nodered_pub credentials. Publish only to the allowed telemetry topic. Select QoS and retained-message behavior according to the tested outage and stale-data policy.

5

Add error and status paths

Route connection failures, timeouts, decode errors, and rejected values to logs and health indicators with a Catch node. Do not convert failures into zero-valued process data. Expose the last successful poll time so stale acquisition is visible.

The transformation logic must be adapted to the verified register map. The following Function node is an example for three already-decoded values, not a universal Modbus decoder:

const values = msg.payload;

if (!Array.isArray(values) || values.length < 3) {
    node.error("Incomplete Modbus response", msg);
    return null;
}

const temperature = values[0] / 100;
const pressure = values[1] / 10;
const motorSpeed = values[2];

if (!Number.isFinite(temperature) ||
    !Number.isFinite(pressure) ||
    !Number.isFinite(motorSpeed)) {
    node.error("Invalid decoded telemetry", msg);
    return null;
}

msg.topic = "factory/site1/line1/press_01/telemetry";
msg.payload = {
    temperature_c: temperature,
    pressure_bar: pressure,
    motor_speed_rpm: motorSpeed,
    quality: "good",
    source_time: new Date().toISOString(),
    site: "site1",
    line: "line1",
    machine: "press_01"
};

return msg;

Replace the divisions, field types, ranges, units, and decoding logic with values confirmed by the equipment documentation. For 32-bit or floating-point values, decode bytes and words explicitly rather than indexing each register as an independent measurement. In this example source_time is the gateway time when the value was processed. If the device provides its own timestamp, use that and label it accordingly.

Initialize InfluxDB 2.x

A fresh InfluxDB 2.x instance must be set up once, which creates the initial administrator user, organization, bucket, and an all-access operator token. You can do this in the web UI at http://127.0.0.1:8086 (through an SSH port forward from your workstation) or with the CLI on the gateway. Run the CLI in interactive mode so it prompts for the password instead of taking it as an argument:

influx setup

When prompted, enter an administrator username and password, the organization name factory, the primary bucket name machines, and a retention period derived from your operational and legal requirements (for example 90d, or 0 for infinite retention). The CLI then saves a connection configuration, including the operator token, under ~/.influxdbv2/ for the user who ran it. That token has full control of the instance. Protect that file, store a copy of the token in the site's secret store as recovery material, and never give it to Telegraf or Grafana.

To change retention later or add buckets, look up the bucket ID and use the bucket commands:

influx bucket list --org factory
influx bucket update --id <BUCKET_ID> --retention 180d
# Additional bucket, if you separate data classes:
influx bucket create --name machines_longterm --org factory --retention 365d

Create a write token for Telegraf and a read-only token for Grafana

Create two narrowly scoped tokens with influx auth create. The --write-bucket and --read-bucket options take the bucket ID from influx bucket list:

influx auth create --org factory \
  --write-bucket <BUCKET_ID> \
  --description "telegraf machines write"

influx auth create --org factory \
  --read-bucket <BUCKET_ID> \
  --description "grafana machines read"

Each command prints the new token. Copy it straight into your secret store. The Telegraf token can only write to machines, and the Grafana token can only read it. If either credential leaks, the attacker cannot delete buckets, create users, or read other data. Revoke a token with influx auth delete --id <AUTH_ID> after creating its replacement.

Store Telegraf secrets in an environment file

Telegraf replaces ${VAR} references in its configuration with environment variables at startup. The Debian package's systemd unit loads /etc/default/telegraf as an environment file, so place the secrets there and keep them out of the configuration itself:

sudo install -m 600 -o root -g root /dev/null /etc/default/telegraf
sudoedit /etc/default/telegraf
MQTT_TELEGRAF_PASSWORD=paste-the-telegraf_sub-password
INFLUX_WRITE_TOKEN=paste-the-telegraf-write-token

Systemd reads this file as root before starting Telegraf, so mode 600 owned by root is sufficient. Recent Telegraf releases also support secret-store plugins (for example the OS keyring or an encrypted file) referenced as @{store:secret}. Use one of those if site policy prohibits secrets in environment files.

Configure Telegraf with an explicit schema

Telegraf subscribes with its read-only MQTT account and writes to InfluxDB with the bucket-scoped token. Use a deliberate measurement name such as machine_telemetry. Treat machine identity as tags only when the set of values is bounded and controlled. Store numeric process values as fields, because changing a field from a number to a string later creates type conflicts.

Back up the packaged /etc/telegraf/telegraf.conf, then review it. Keep the [agent] section, and comment out any default output or input sections you do not intend to run, in particular a legacy [[outputs.influxdb]] block. Put the pipeline in /etc/telegraf/telegraf.d/factory.conf:

[[inputs.mqtt_consumer]]
  servers = ["tcp://127.0.0.1:1883"]
  topics = ["factory/+/+/+/telemetry"]
  username = "telegraf_sub"
  password = "${MQTT_TELEGRAF_PASSWORD}"
  qos = 1
  data_format = "json"
  name_override = "machine_telemetry"
  tag_keys = ["site", "line", "machine", "quality"]
  json_time_key = "source_time"
  json_time_format = "2006-01-02T15:04:05.999999999Z07:00"

[[outputs.influxdb_v2]]
  urls = ["http://127.0.0.1:8086"]
  token = "${INFLUX_WRITE_TOKEN}"
  organization = "factory"
  bucket = "machines"

By default the MQTT consumer also adds the source topic as a topic tag. That is useful for diagnostics, but it duplicates the identity tags. Set topic_tag = "" in the input if you want to suppress it. Set sudo chmod 640 /etc/telegraf/telegraf.d/factory.conf with group telegraf so only the service and administrators can read it.

Test Telegraf before starting the service

Telegraf's --test mode gathers metrics and prints them to standard output without writing to outputs. Because the MQTT consumer is a service input that waits for messages, add --test-wait so it listens for a few seconds. When you run Telegraf by hand, systemd is not loading /etc/default/telegraf, so export the variables for that single command:

sudo bash -c 'set -a; . /etc/default/telegraf; set +a; \
  telegraf --config /etc/telegraf/telegraf.conf \
           --config-directory /etc/telegraf/telegraf.d \
           --input-filter mqtt_consumer --test --test-wait 15'

With the Node-RED flow publishing, you should see lines beginning with machine_telemetry that carry the tags and numeric fields you expect. If nothing appears, the problem is upstream (Node-RED, the ACL, or the broker), not in InfluxDB. To prove that the output path works as well, run the same command with --once instead of --test --test-wait 15. It gathers once, writes to the configured outputs, and exits. Service inputs may need a published message within that window, so use the test mode as the primary parser check. Then start the service and watch its journal:

sudo systemctl start telegraf
sudo journalctl -u telegraf -f

QoS 1 can deliver duplicate messages. InfluxDB treats two points with the same measurement, tag set, field, and timestamp as the same point, and the later write overwrites the earlier one. That helps only when the timestamp originates at the source. If duplicate elimination is a requirement, assign a stable source timestamp or event identifier and design an idempotency policy. Do not rely on arrival order during reconnects.

Confirm the stored data

Query recent data with the CLI, which uses the operator configuration saved by influx setup:

influx query 'from(bucket: "machines")
  |> range(start: -15m)
  |> filter(fn: (r) => r._measurement == "machine_telemetry")
  |> last()'

Confirm that machine_telemetry exists, tags contain the intended identities, fields are numeric, and timestamps correspond to the source events. A successful MQTT subscription does not prove that Telegraf parsed or wrote the fields correctly.

Configure Grafana, dashboards, and stale-data alerts

Grafana dashboard comparing live machine data with a stale data condition.
A freshness alert compares the current time with the timestamp of the latest stored sample.

Open Grafana from your management workstation through an SSH port forward, for example ssh -L 3000:127.0.0.1:3000 user@gateway, then browse to http://localhost:3000. A new Grafana installation signs in with the username admin and password admin and immediately asks you to set a new password. Do not skip that prompt. Choose a strong password from your secret store, and complete this step before any tunnel exists, so the default credential is never reachable from the internet.

Then create individual accounts for remote viewers with the Viewer role, and reserve Editor and Admin roles for named maintainers. Self-registration is disabled by default (allow_sign_up = false under [users] in grafana.ini), so keep it that way. Menu paths vary between Grafana releases. In current interfaces, users are under Administration and data sources under Connections, while older releases place them under Configuration.

1

Add the InfluxDB data source

Select InfluxDB and choose Flux as the query language, which matches the InfluxDB 2.x setup in this guide. Set the URL to http://127.0.0.1:8086, the organization to factory, the default bucket to machines, and the token to the read-only Grafana token. Save and test the connection.

2

Verify the stored schema before designing panels

Use the query editor to inspect actual measurement, field, and tag names. Confirm that the schema contains machine_telemetry, the expected machine tag, and fields such as temperature_c.

3

Create operational panels

Use a Stat panel for the latest valid value, a Time series panel for trends, and a Gauge only when its thresholds are documented engineering limits. Display units explicitly and distinguish no data from a measured zero.

4

Configure refresh and alert evaluation intervals

Choose intervals based on measured pipeline latency, database load, and operational need. Grafana alert evaluation frequency is configurable and must not be assumed to be one minute.

With the explicit Telegraf measurement above, a temperature query can begin as follows:

from(bucket: "machines")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "machine_telemetry")
  |> filter(fn: (r) => r["site"] == "site1")
  |> filter(fn: (r) => r["line"] == "line1")
  |> filter(fn: (r) => r["machine"] == "press_01")
  |> filter(fn: (r) => r["_field"] == "temperature_c")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)

The v.timeRangeStart, v.timeRangeStop, and v.windowPeriod variables let the panel follow the dashboard time picker instead of a fixed range. Verify this query against the actual Telegraf output before treating it as final. If the measurement is missing, inspect Telegraf parsing rather than changing Grafana filters at random.

Alert on stale and missing data as well as thresholds

A temperature alert alone cannot distinguish a healthy machine from a broken collection pipeline. Add a stale-data rule based on the age of the latest valid sample, and define how Grafana handles no-data and query-error states. Set the stale threshold above the normal measured polling, buffering, and refresh delay, then test it by stopping acquisition in a controlled maintenance window.

Expose only Grafana through Localtonet

With Localtonet, the client on the gateway establishes an outbound connection to one of our relay servers. The resulting HTTP tunnel gives Grafana a public HTTPS address without inbound router port forwarding, inbound firewall rules, VPN setup, or a public IP address. The tunnel does not make the rest of the gateway public unless you deliberately configure additional tunnels.

Before you start, confirm that the Localtonet client is installed on the gateway and connected with its AuthToken, and that Grafana answers locally on 127.0.0.1:3000. Treat the AuthToken as a secret and never place it in screenshots, documentation, or shared shell history. The steps below follow our HTTP tunnel documentation.

1

Open the HTTP tunnel form

In the Localtonet dashboard, open My Tunnels › HTTP and select Create HTTP Tunnel.

2

Choose the URL type

Select Random subdomain, Custom subdomain, or Custom domain. A random subdomain needs nothing extra. Custom subdomain and Custom domain require balance on your account, and Custom domain also requires a domain that you have added in DNS Manager.

3

Choose the device and the region

In Device token, select the token used by the Localtonet app on the gateway. In Server region, choose a region close to the gateway for lower latency.

4

Enter the local address

Select the Domain, enter a Subdomain if you chose Custom subdomain, set Local IP address to 127.0.0.1 and Local port to 3000.

5

Create the tunnel

Select Create tunnel. The tunnel appears under Your tunnels as Tunnel # followed by its ID. Creating it does not start it.

6

Start the tunnel

Select the start button in the Actions column. When the tunnel runs, its address in the URL column becomes a link. If the Localtonet app for that token is offline, a dialog tells you so. Start the app, or select Start anyway, and the tunnel goes live when the app connects.

Turn on "Is Only Https?" before anyone signs in

Grafana carries logins and session cookies. Open the tunnel's Settings and enable Is Only Https?, which serves the public URL over HTTPS only and redirects http:// requests to https://. While it is off, the address answers on both. Also keep the tunnel protected with SSO or another access control described below. Until you protect it, an HTTP tunnel is open to anyone who has its address.

How the HTTP tunnel behaves with Grafana

  • Stable address. An HTTP tunnel keeps its subdomain until you delete the tunnel. Stopping and starting it does not change the address, so the Grafana settings below stay valid across restarts.
  • TLS termination. Visitors connect over HTTPS with a certificate that Localtonet provides and renews. TLS ends at the Localtonet server, and the request then travels through the tunnel to the client on the gateway, which passes it to Grafana on plain HTTP at 127.0.0.1:3000.
  • Host header. Grafana receives the host name the visitor used, which is the tunnel address. That is why Grafana must know its public URL.
  • WebSockets. WebSocket connections pass through an HTTP tunnel, which matters for Grafana Live features that stream updates to the browser.

Tell Grafana its public URL

Grafana builds redirects, login links, and some asset URLs from its root_url. If it still believes it lives at http://localhost:3000, sign-in redirects can send remote browsers to an unreachable address. Copy the host name from the URL column and update the [server] section of /etc/grafana/grafana.ini:

[server]
http_addr = 127.0.0.1
http_port = 3000
domain = your-tunnel-host.localto.net
root_url = https://your-tunnel-host.localto.net/

[security]
cookie_secure = true

Replace the example host with the actual tunnel host name. cookie_secure makes Grafana mark its session cookie as HTTPS-only, which fits the HTTPS-only tunnel. Restart with sudo systemctl restart grafana-server. Local access through the SSH forward still works after this change, although Grafana may generate links pointing at the public URL.

Add SSO in front of Grafana

Localtonet SSO puts a sign-in page in front of an HTTP tunnel. Visitors sign in with an identity provider you choose before any request reaches Grafana, and Grafana never sees that password. The dashboard's Provider type list contains Username-Password, Google, GitHub, Microsoft, OpenID Connect, Discord, Twitter (X), Custom, Facebook, Apple, LinkedIn, GitLab, Slack, Spotify, Twitch, Reddit, Bitbucket, Amazon, and Yahoo. Username-Password uses accounts you define in Localtonet with no external provider. It is not the same as the separate Basic Authentication tunnel setting.

SSO requires balance on your account. Without it, saving a provider or turning on sign-in fails with "You need to purchase balance to use this feature." SSO is set up in your personal dashboard. The SSO button and the SSO Providers setting are not shown for team tunnels. Setup has two parts: you add a provider once, then turn it on for each tunnel you want to protect. A saved provider protects nothing until a tunnel uses it.

1

Add a provider

Open My Tunnels › HTTP and select SSO at the top of the page. In the SSO providers dialog, select Add provider, fill in the provider name, type, and (for external providers) Client ID and Client secret, then select Save provider.

2

Turn it on for the Grafana tunnel

Under Your tunnels, select Settings on the Grafana tunnel. Find SSO Providers and select Manage. Turn on Require sign-in, switch on at least one provider, optionally fill in Who can sign in, and select Save.

3

Test it

Open the tunnel URL in a private browser window. You should arrive on the Sign in to continue page, and after signing in, on the Grafana login page.

For an external provider such as Google, GitHub, Microsoft, or GitLab, register an OAuth application at the provider and enter the redirect URI exactly as our Single Sign-On documentation shows it: http://auth.localtonet.com/auth/callback. It is an address on our sign-in host, not your tunnel address, and providers compare it character by character. Leave the Callback path under Endpoints & callback as it is filled in.

Access rules work at two levels, and both apply. At the provider level you can set allowed email domains, blocked email domains, and blocked email addresses. At the tunnel level, Who can sign in accepts lists of email addresses, email domains, and usernames. A visitor who signs in but is not allowed by these rules receives 403 - Access Denied with the text "You do not have permission to access this tunnel." For a factory dashboard, restrict sign-in to your organization's domain and, where practical, to named maintainers and viewers.

SSO is browser-only

A request that does not carry the sign-in cookie is redirected to the sign-in page, so scripts, API clients, and webhooks cannot pass. If anything calls the Grafana HTTP API through the tunnel, for example a reporting script, SSO will block it. Either protect only selected paths with the Sign-in paths option or use one of the other access controls for that traffic. Keep Grafana's own login enabled as a second layer, and give remote users the Viewer role.

Other hardening settings for the tunnel

The tunnel's Settings panel offers further controls. Enable the ones that match your access policy:

  • IP Restriction controls which client IP addresses can access the tunnel, useful when remote viewers come from known corporate egress addresses.
  • Basic Authentication? asks visitors for a username and password, a simpler alternative when SSO is not used.
  • WAF, from the button in the Actions column, configures the Web Application Firewall for the tunnel.
  • Request Log and Activity Log let you inspect requests and review starts, stops, and setting changes.
  • Expiration Date stops the tunnel on a date, which suits temporary remote access for a commissioning or support period.
  • Outbound Port uses fixed outbound ports for the client's server connection, which helps when the site firewall permits only specific outbound ports.

Our HTTP tunnel documentation also covers a warning page shown on the Free plan. Review it before sharing the address with operators. Do not assume every option or region is included in every subscription plan, and confirm current availability for the account before making it part of the operational design.

Tunnel availability has two conditions

The public endpoint works only while the selected Localtonet client is connected and the tunnel is running. A gateway reboot, client failure, blocked outbound connection, stopped tunnel, or deleted tunnel will make the address unavailable. Deleting the tunnel also releases its subdomain, so a new tunnel needs an updated root_url in Grafana.

Verify each component and the complete path

Test one boundary at a time before testing remote access. Record the time, component version, configuration revision, machine identity, expected value, observed value, and result. This makes later troubleshooting far more reliable than changing several services at once.

Test MQTT credentials without exposing passwords

mosquitto_pub and mosquitto_sub read default options from ~/.config/mosquitto_pub and ~/.config/mosquitto_sub. Put test credentials there with mode 600 instead of using -P on the command line. For example, ~/.config/mosquitto_sub for the subscriber account:

-h 127.0.0.1
-u telegraf_sub
-P paste-the-password-here
chmod 600 ~/.config/mosquitto_sub ~/.config/mosquitto_pub
mosquitto_sub -t 'factory/+/+/+/telemetry' -v
# In a second shell, with ~/.config/mosquitto_pub set to nodered_pub:
mosquitto_pub -t 'factory/site1/line1/test_01/telemetry' -m '{"temperature_c":21.5,"quality":"test","site":"site1","line":"line1","machine":"test_01","source_time":"2026-01-01T00:00:00Z"}'

The subscriber should print the message. Then confirm the ACL denies operations it should deny: publish as nodered_pub to factory/site1/other, or try subscribing as nodered_pub. Mosquitto does not report ACL denials to QoS 0 clients as errors, so verify that the message never arrives rather than waiting for an error. Delete the test files and any test data in InfluxDB afterwards.

Local component checks

  1. Confirm the gateway clock is synchronized with timedatectl and record its offset from the approved time source.
  2. Confirm the listeners with ss -ltnp: Mosquitto on 127.0.0.1:1883, Node-RED on 127.0.0.1:1880, InfluxDB on 127.0.0.1:8086, Grafana on 127.0.0.1:3000.
  3. Verify the Modbus endpoint is reachable only from the intended gateway path.
  4. Read a small approved register range and compare the decoded result with the PLC, HMI, vendor utility, or another authoritative source.
  5. Confirm Node-RED rejects incomplete responses and logs Modbus exception or timeout details.
  6. Confirm the Node-RED editor demands the adminAuth login.
  7. Run the Telegraf test command and confirm the measurement, tags, and numeric fields.
  8. Query InfluxDB directly and compare stored field values and timestamps with the published payload.
  9. Run the Grafana query and verify that the expected series appears without renaming anything to hide a schema error.
  10. Stop polling briefly in an approved window and confirm the dashboard indicates stale or missing data rather than displaying the last value as current indefinitely.

End-to-end remote checklist

  1. Confirm Grafana works locally and the default admin password has been changed.
  2. Confirm the Localtonet client is connected with the intended device token.
  3. Confirm the HTTP tunnel targets only 127.0.0.1:3000 and Is Only Https? is on.
  4. Open http:// plus the tunnel host and confirm it redirects to HTTPS.
  5. From an external network without plant-network access, open the address in a private window and confirm the Sign in to continue page appears before Grafana.
  6. Sign in with an account outside the access rules and confirm the 403 Access Denied response.
  7. Sign in as a Grafana Viewer and confirm dashboards are visible but administrative changes are unavailable. Confirm that redirects stay on the tunnel host name.
  8. Compare the displayed value and timestamp with the source to measure source-to-screen latency.
  9. Stop the tunnel and confirm the remote endpoint becomes unavailable while local Grafana remains operational.
  10. Reboot the gateway during a maintenance test and confirm that mosquitto, nodered, influxdb, telegraf, grafana-server, and the Localtonet client all return. Record the actual data gap rather than estimating it.

Secure operation, maintenance, and failure planning

A working demonstration is not yet an operational service. Assign owners for the gateway, Node-RED flows, broker ACLs, database, dashboards, Localtonet tunnel, credentials, backups, and incident response. Store configuration in a controlled repository without secrets, and require review for register-map, scaling, topic, retention, firewall, or alert changes.

🔑 Credential lifecycle Rotate MQTT passwords with mosquitto_passwd, replace InfluxDB tokens with influx auth create then delete the old ones, and update /etc/default/telegraf. Rotate Grafana and Node-RED credentials and the device token by policy. Test rotation in staging so an update does not silently stop collection.
🩹 Controlled patching Track supported releases and security advisories for every package source. Back up configuration, test upgrades against representative telemetry, schedule an approved window, and maintain a rollback plan. Recheck Node-RED's Node.js requirement before major upgrades.
💾 Backup and restore Back up InfluxDB with influx backup using the operator token, plus ~/.node-red, /etc/mosquitto, /etc/telegraf, and /etc/grafana with the Grafana database. Protect secrets separately and perform restore tests.
📈 Capacity and disk monitoring Alert on disk utilization, database growth, write failures, I/O latency, memory pressure, queue growth, and retention behavior. A full disk can stop ingestion and may affect several services at once.
🧾 Logs and audit trail Retain service starts, authentication failures, ACL denials, Modbus exceptions, configuration changes, Grafana sign-ins, and alert outcomes. Also retain the tunnel's Request Log and Activity Log entries according to site policy.
🚨 Incident response Define the response sequence: stop the Localtonet tunnel, revoke the device token, deactivate SSO providers or remove users, disable Grafana accounts, and isolate the gateway. Then preserve logs, restore trusted configuration, and verify the monitoring path before returning it to service.

Document failure behavior explicitly. During a Modbus outage, values should become stale and alarms should indicate data loss. During an MQTT or Telegraf outage, queued data may be limited or lost depending on tested settings. During an InfluxDB outage, dashboard history and writes can fail. During a Localtonet outage, local monitoring continues while remote access is unavailable. None of these failures should affect the PLC's independent control or safety functions.

Review outbound firewall requirements with the network owner. Permit only what the gateway needs for approved DNS, time synchronization, package updates, and Localtonet connectivity. Use the Outbound Port setting if the site requires fixed ports. An outbound tunnel does not bypass network policy. It must be explicitly authorized and documented like any other remote-access path.

Symptom-based troubleshooting

Symptom Likely checks Safe next action
Modbus connection fails IP route, firewall, port, serial settings, dialout membership, unit ID, device connection limit, timeout, gateway mode Test one approved read, inspect node-red-log and device logs, and confirm that no unapproved poller is exhausting connections.
Values are plausible but wrong Zero-based versus 40001 notation, function code, signedness, scale, byte order, word order Compare raw registers and decoded values with a known operating point and vendor documentation.
Mosquitto will not start after configuration Typo in factory.conf, duplicate listener, missing password or ACL file, file permissions Read /var/log/mosquitto/mosquitto.log and journalctl -u mosquitto, fix the named line, and restart.
MQTT authentication fails Username, password file entry, file ownership, broker listener, restart after changes Reset the password interactively with mosquitto_passwd, restart the broker, and check its log.
MQTT connection works but publish or subscribe is silently ignored ACL username block, topic depth, wildcard pattern, read versus write permission Compare the exact topic with the ACL and grant only the minimum missing permission.
Telegraf test shows no metrics Nothing publishing, wrong topic filter, environment variables not loaded, test window too short Watch with mosquitto_sub, export /etc/default/telegraf for the manual run, and increase --test-wait.
Telegraf receives messages but writes no fields Invalid JSON, timestamp format, strings where numbers are expected, field type conflict Capture a sanitized payload, rerun the test, and inspect the Telegraf journal before changing InfluxDB.
InfluxDB rejects writes with an authorization error Token scope, bucket ID used in influx auth create, organization name, unresolved ${INFLUX_WRITE_TOKEN} Check the token's permissions with influx auth list and confirm systemd loads the environment file.
Grafana shows no data Time range, measurement name, field name, tags, data-source token, Flux selected as query language Query InfluxDB directly, inspect the actual schema, then align the Flux filters with stored values.
Dashboard shows old values as current Retained MQTT message, missing source timestamp, absent stale rule, stopped polling Display sample age, configure no-data handling, and verify the last successful acquisition timestamp.
Remote login redirects to localhost or loops root_url and domain not set to the tunnel host, Grafana not restarted Set both values in grafana.ini to the exact tunnel host and restart grafana-server.
Localtonet URL is unavailable Client connection, selected token, outbound firewall, tunnel not started, local IP and port, Grafana service Verify Grafana locally, confirm the client is connected, and check that the URL column shows a link.
SSO provider cannot be saved or sign-in fails at the provider Account balance, team tunnel, redirect URI mismatch, inactive provider Add balance, use a personal tunnel, and register the redirect URI exactly as documented.
A script calling Grafana through the tunnel gets the sign-in page SSO requires a browser sign-in cookie Run the script locally or use Sign-in paths or another access control for that traffic.
Remote login works but the user can edit dashboards Grafana role, team membership, organization permissions, shared admin account Remove excessive privileges and assign a dedicated Viewer identity. Do not share an administrative login.

Always start with the earliest failing boundary. If the Modbus read is wrong, changing Grafana cannot repair it. If InfluxDB has the correct point but Grafana does not show it, focus on the query and time range. If Grafana works locally but not remotely, focus on the Localtonet client, tunnel state, SSO configuration, and Grafana's root_url.

Frequently asked questions

Is this a real-time industrial control system?

No. It is a near-real-time monitoring system. Poll intervals, MQTT delivery, Telegraf buffering, database writes, Grafana queries, and browser refreshes all add latency. It must not be used for deterministic control, interlocks, emergency stops, or functional safety.

Can I use InfluxDB 3 instead of InfluxDB 2.x?

Not with this guide as written. InfluxDB 3 does not support Flux, so the Grafana queries here will not work. Grafana must use SQL or InfluxQL against InfluxDB 3, and installation, database creation, and token management follow a different procedure. Every database step in this article targets InfluxDB 2.x.

Can this monitor a Modbus RTU device?

Yes, if the integration method is configured correctly. A protocol-converting RTU-to-TCP gateway can present a Modbus TCP endpoint. A transparent serial server may only transport serial bytes and is not necessarily a protocol converter. A USB-to-RS485 adapter provides a local serial interface. It requires the serial client type in node-red-contrib-modbus and serial-port permissions for the Node-RED service user.

Will all components restart automatically after a gateway reboot?

Only if each systemd service is enabled: mosquitto, nodered, influxdb, telegraf, and grafana-server, plus the Localtonet client's startup method. Node-RED does not restart after a reboot if it was launched from a terminal. Test a controlled reboot, inspect every service, and record the actual collection gap.

Do I need both Localtonet SSO and the Grafana login?

We recommend both. SSO stops unauthenticated visitors before any request reaches Grafana and applies your email domain and username rules. Grafana's login then controls roles inside the application, so remote users can be Viewers. SSO requires account balance and is browser-only, so plan separately for any scripted access.

How many machines can one gateway monitor?

There is no reliable universal device count. Capacity depends on polling intervals, registers per request, response time, device connection limits, transformation complexity, payload size, storage performance, query load, and retention. Run a representative pilot, measure resource use and failure rates, then size the gateway with operational headroom.

How much disk space does InfluxDB require?

Measure it with representative data. Record database growth per day under normal and peak load, multiply by the bucket's retention period, and add space for logs, compaction, backups, upgrades, and recovery operations. Field count, tag cardinality, write frequency, and data shape all affect storage, so a generic monthly estimate is not dependable.

What happens to telemetry during an outage?

Behavior depends on which component failed and on the tested persistence and queue settings. A gateway reboot stops polling. MQTT QoS 0 can lose messages, while QoS 1 can redeliver duplicates. Broker and Telegraf queues are finite, and a database outage can exhaust buffers. Define acceptable data loss, test realistic outages, and make stale data visible.

Does remote access require a cloud service?

The MQTT broker, Node-RED flow, InfluxDB database, and Grafana dashboard are self-hosted in this design. Remote access through Localtonet requires a Localtonet account, a connected client, a running tunnel, and our relay service. TLS for visitors ends at the Localtonet server. Local monitoring continues independently if the remote tunnel is unavailable.

Provide controlled remote access to your self-hosted Grafana dashboard

Before going remote, validate the read-only telemetry path, service startup, local credentials, stale-data behavior, backups, and OT network controls. Then create a Localtonet HTTP tunnel that targets only Grafana, turn on HTTPS-only, and put SSO in front of it. Keep the tunnel stopped, or set an expiration date, when remote access is not required.

Get Started Free →

Corrections & updates

Substantive changes approved by the Localtonet editorial team are listed transparently below.

Reviewed and updated for accuracy and completeness.

Reviewed and updated for accuracy and completeness.

Localtonet is a secure multi-protocol tunneling and proxy platform designed to expose localhost, devices, private services, and AI agents to the public internet supporting HTTP/HTTPS tunnels, TCP/UDP forwarding, mobile proxy infrastructure, file server publishing, latency-optimized game connectivity, and developer-ready AI agent endpoint exposure from a single unified control plane.

Support