uns-dashboard — Grafana Dashboards
5 Grafana dashboards for real-time manufacturing visibility — machine status, production, tooling, status log, and KPI overview.
| Type | Grafana dashboards (JSON) |
| Datasource | PostgreSQL (read-only) |
| Depends on | uns-historian, uns-log |
| Dashboards | 5 (Machine Overview, Production, Tooling, Status Log, KPI Overview) |
What It Does
Provides a complete Grafana presentation layer for the UNS Framework. Queries PostgreSQL directly using SQL with window functions for accurate duration-based metrics and deduplication. No intermediate functions or caches — just SQL and Grafana.
Dashboards
| Dashboard | Source | Key Panels |
|---|---|---|
| Machine Overview | uns_historian | Status timeline, spindle RPM, feed rate, uptime, status distribution (time-based) |
| Production | uns_historian | Program progress gauge, parts vs target, cycle time, deduplicated program history |
| Tooling | uns_historian | Tool life gauge, offset trend (wear detection), deduplicated tool change history |
| Status Log | uns_log | Status timeline, time-based distribution, full change log with changed fields |
| KPI Overview | uns_historian | Utilisation %, availability %, MTBF/MTTR, stoppage pareto, throughput metrics |
KPI Dashboard
The KPI Overview dashboard computes the same manufacturing KPIs as uns-kpi, but directly in SQL using window functions:
| KPI | Panel Type | Calculation |
|---|---|---|
| Utilisation % | Gauge | ACTIVE time / total tracked time |
| Availability % | Gauge | (total - ALARM - OFFLINE) / total |
| MTBF | Stat | Avg ACTIVE run duration (minutes) |
| MTTR | Stat | Avg ALARM duration (minutes) |
| Stoppage Pareto | Bar Chart | Non-productive states ranked by total time |
| Throughput | Stat | Parts completed, target attainment % |
Key Techniques
Duration-Based Metrics
All pie charts and KPIs use LEAD() window functions to compute actual time spent in each state, rather than counting rows. This gives accurate results even when the historian logs at fixed 3-second intervals.
Deduplication
All tables use LAG() window functions to compare each row with the previous one, only showing rows where values actually changed. This eliminates repetitive rows from periodic polling.
Status Colours
Consistent colour mapping across all dashboards: ACTIVE=green, IDLE=yellow, ALARM=red, OFFLINE=gray, SETUP=blue, WAITING=orange.
Template Variables
All dashboards include machine and area multi-select variables. Filter by any machine or area, or view all at once.
Quick Start
# Push all dashboards to an existing Grafana instance
cd uns-dashboard
for f in grafana/dashboards/*.json; do
curl -X POST $GRAFANA_URL/api/dashboards/db \
-H "Authorization: Bearer $GRAFANA_TOKEN" \
-H "Content-Type: application/json" \
-d @$f
done
# Or deploy with Docker Compose
cp .env.example .env && docker compose up -d
open http://localhost:3001File Structure
uns-dashboard/ ├── grafana/dashboards/ │ ├── machine-overview.json # 9 panels │ ├── production.json # 10 panels │ ├── tooling.json # 10 panels │ ├── status-log.json # 7 panels │ └── kpi.json # 15 panels ├── grafana/provisioning/ # Auto-config datasource + dashboards ├── docker-compose.yml └── .env.example
Architecture Context
uns-sim → MQTT → uns-framework → Valkey
│
uns-historian ← MQTT ──┘
uns-log ← HTTP
│
▼
PostgreSQL
uns_historian
uns_log
│
▼
uns-dashboard (Grafana)
← pure read, SQL queries →