Visualizing Raspberry Pi Data with Grafana Cloud (Free Tier)
Grafana is a visualization tool that excels at graphing time-series data, creating dashboards and sending alerts when thresholds are exceeded.
This page describes how to use the free tier (Free) of "Grafana Cloud", the cloud version provided by Grafana Labs, so that PLC data recorded in MariaDB on a Raspberry Pi can be viewed from PCs and smartphones in the office or on the go.
If you want to keep everything within the company LAN, use "Metabase".
Configuration
The key is the PDC agent (Private Data Source Connect) running on the Raspberry Pi. The agent opens an encrypted tunnel (SSH) from the Raspberry Pi to Grafana Cloud, and Grafana Cloud queries MariaDB through that tunnel.
- No inbound ports need to be opened on routers or firewalls (it works with outbound connections only)
- Data stays in MariaDB on the Raspberry Pi, so it is not subject to the cloud retention limit (14 days)
- MariaDB is not exposed to the internet, which is safer than putting the DB directly online
What the free tier includes
The main contents of the free tier (Free) as of October 2026. You can start without registering a credit card.
| Item | Free tier | Effect in this configuration |
|---|---|---|
| Grafana (dashboards) | Up to 3 active users per month | Free if up to 3 people view and edit |
| Private Data Source Connect | Available | Used to connect to MariaDB |
| Metrics | 10k active series/month, 14-day retention | Not used, because MariaDB is queried directly |
| Logs and traces | 50 GB/month each, 14-day retention | Not used |
| Alerts | Available | Threshold breaches can be notified by email etc. |
| Support | Community support only |
* The free tier contents may change. Check the latest information on the Grafana Cloud pricing page.
Comparison of Metabase and Grafana
| Metabase (on the Raspberry Pi) | Grafana Cloud (free tier) | |
|---|---|---|
| Where it runs | Raspberry Pi | Cloud (only the agent on the Raspberry Pi) |
| Load on the Raspberry Pi | High (Java, about 1 GB of memory) | Low (the agent is a few tens of MB) |
| Internet | Not needed | Required (outbound only) |
| From outside / smartphones | VPN etc. required | Viewable as is |
| Strengths | Summary tables, analysis without SQL | Time-series trends, real-time monitoring, alerts |
| Number of users | Unlimited | Up to 3 per month (free tier) |
Preparing sample data
Create a table to display in Grafana. If you already have a table recording PLC data, use that table.
$ sudo mariadbUSE testDB; -- Table recording values read from the PLC (example) CREATE TABLE plc_log ( id INT AUTO_INCREMENT PRIMARY KEY, ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, device VARCHAR(32) NOT NULL, value DOUBLE ); CREATE INDEX idx_plc_log_ts ON plc_log (ts); -- Test data (60 rows, one per minute for the last hour) INSERT INTO plc_log (ts, device, value) SELECT NOW() - INTERVAL seq MINUTE, 'PLC1', 20 + RAND() * 10 FROM seq_0_to_59; SELECT COUNT(*) FROM plc_log;
CONVERT_TZ(ts,'+09:00','+00:00')).
Read-only user for Grafana
Grafana only reads data, so create a user with only SELECT privileges. The PDC agent connects to MariaDB from the Raspberry Pi itself, so the source is limited to 127.0.0.1.
CREATE USER 'grafana'@'127.0.0.1' IDENTIFIED BY 'grafana_pass'; GRANT SELECT ON testDB.* TO 'grafana'@'127.0.0.1'; EXIT;
Change the password to something hard to guess.
Creating a Grafana Cloud account
- Sign up on the Grafana Cloud sign-up page with an email address or a Google/GitHub account.
- Decide the name and region of your stack (your own Grafana environment). The stack name becomes the URL (
https://your-stack-name.grafana.net). Choosing a region close to you makes the display faster. - When creation finishes, you can log in to your stack's Grafana. The following operations are done on this Grafana screen.
Setting up the PDC agent
1. Create a PDC network and token (Grafana Cloud side)
- Open Connections > Private data source connections from the Grafana left menu.
- Create a network with Add new network (for example, name it
raspi-factory). - On the Configuration Details tab of the created network, press Create a new token to issue a token.
- Note down the following three values shown on screen.
| Item on screen | Variable name on this page | Example |
|---|---|---|
| token | GCLOUD_PDC_SIGNING_TOKEN | glc_eyJvIjoi… (long string) |
| cluster | GCLOUD_PDC_CLUSTER | prod-ap-northeast-0, etc. |
| gcloud-hosted-grafana-id | GCLOUD_HOSTED_GRAFANA_ID | 123456, etc. |
2. Install the agent (Raspberry Pi side)
The PDC agent requires OpenSSH 9.2 or later. Raspberry Pi OS Bookworm or later meets this requirement.
$ ssh -V
OpenSSH_9.2p1 Debian-2+deb12u3, OpenSSL 3.0.15 3 Sep 2024Download the agent for ARM64 (64-bit OS) and place it in /usr/local/bin.
$ cd ~ $ wget https://github.com/grafana/pdc-agent/releases/latest/download/pdc-agent_Linux_arm64.tar.gz $ tar xzf pdc-agent_Linux_arm64.tar.gz $ sudo install -m 755 pdc-agent_Linux_arm64/pdc /usr/local/bin/pdc $ pdc -version
uname -m returns aarch64.
3. Start manually and check the connection
Start it with the three values you noted (a single-line command).
$ pdc -token <GCLOUD_PDC_SIGNING_TOKEN> -cluster <GCLOUD_PDC_CLUSTER> -gcloud-hosted-grafana-id <GCLOUD_HOSTED_GRAFANA_ID>If the log shows This is Grafana Private Data Source Connect!, the connection succeeded. You can also confirm on the Private data source connections screen in Grafana Cloud that the agent is connected (Connected). Once confirmed, stop it with Ctrl+C.
4. Start automatically as a service
Write values such as the token in a separate configuration file and make it unreadable by other users.
$ sudo nano /etc/default/pdc-agentGCLOUD_PDC_SIGNING_TOKEN=glc_YOUR_TOKEN_HERE GCLOUD_PDC_CLUSTER=YOUR_CLUSTER_HERE GCLOUD_HOSTED_GRAFANA_ID=YOUR_ID_HERE
$ sudo chmod 600 /etc/default/pdc-agent $ sudo nano /etc/systemd/system/pdc-agent.service
[Unit]
Description=Grafana Private Data Source Connect agent
After=network-online.target mariadb.service
Wants=network-online.target
[Service]
EnvironmentFile=/etc/default/pdc-agent
ExecStart=/usr/local/bin/pdc -token ${GCLOUD_PDC_SIGNING_TOKEN} -cluster ${GCLOUD_PDC_CLUSTER} -gcloud-hosted-grafana-id ${GCLOUD_HOSTED_GRAFANA_ID}
User=pi
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target$ sudo systemctl daemon-reload $ sudo systemctl enable --now pdc-agent.service $ journalctl -u pdc-agent -f
It will now connect to Grafana Cloud automatically even after the Raspberry Pi restarts.
Adding the data source (MariaDB)
- Open Connections > Data sources > Add new data source from the Grafana left menu and select MySQL (MariaDB is also connected as MySQL).
- Enter the following.
| Item | Setting | Description |
|---|---|---|
| Host URL | 127.0.0.1:3306 | MariaDB address as seen from the Raspberry Pi |
| Database name | testDB | |
| Username/Password | grafana/grafana_pass | Read-only user |
| Private data source connect | raspi-factory | Select the PDC network you created (this is important) |
- Press Save & test at the bottom; if
Database Connection OKappears, the connection succeeded.
127.0.0.1 and fails.
Creating the dashboard
- Select Dashboards > New > New dashboard > Add visualization from the left menu and choose the MySQL data source you created.
- Switch the query editor to Code and enter the following SQL.
SELECT ts AS time, value AS "PLC1" FROM plc_log WHERE device = 'PLC1' AND $__timeFilter(ts) ORDER BY ts
$__timeFilter(ts)is a Grafana macro that is automatically replaced with the condition for the period selected at the top right (such as the last hour).- If the time column is named
time, Grafana treats it as the horizontal axis. - Setting the refresh interval at the top right (e.g. 10s) updates the graph automatically.
Save the panel and the dashboard, and you are done. From a smartphone too, you can see the same dashboard by logging in to https://your-stack-name.grafana.net.
Setting up alerts (optional)
From the Alert tab in the panel edit screen, you can create alert rules such as "notify by email when the value exceeds 30". Besides email, notification destinations (Contact points) include Slack, Microsoft Teams and more.
Operational notes
- Number of users: the free tier allows up to 3 active users per month. If more people need to view it, consider dashboard sharing (snapshots) or a paid plan.
- Query load: each time the dashboard is opened, SQL is sent through the tunnel to MariaDB on the Raspberry Pi. As data grows, always add an index on the
tscolumn and do not make the refresh interval too short. - Check company rules: factory data will be displayed in a cloud outside the company. Check your company's information security rules before introducing it.
- Updating the agent: the PDC agent is updated irregularly. To update, replace
pdcwith the new one using the same steps and runsudo systemctl restart pdc-agent.
Summary
Just by installing the PDC agent on the Raspberry Pi, MariaDB data could be visualized from the Grafana Cloud free tier without opening ports.
If you keep recording PLC data in MariaDB, you can check equipment operating status in real time from the office or on the go.
Related pages

Initial setup and server construction
Setup steps for static IP, Apache, PHP and MariaDB

Metabase setup
Runs the BI tool Metabase on the Raspberry Pi and graphs MariaDB data

KEYENCE Host Link communication
Host Link communication with KEYENCE PLCs from Python

What is a Raspberry Pi
Introduces the history, specs of current models and PLC integration configurations
Reference
- Grafana Cloud pricing (free tier contents)
- Grafana Cloud documentation: Private data source connect
- Grafana Cloud documentation: Configure PDC
- grafana/pdc-agent(GitHub)
- Grafana documentation: MySQL data source
Raspberry Pi is a trademark of Raspberry Pi Ltd. Grafana is a trademark of Grafana Labs.
