uns-dashboard — Grafana Dashboards

5 Grafana dashboards for real-time manufacturing visibility — machine status, production, tooling, status log, and KPI overview.

TypeGrafana dashboards (JSON)
DatasourcePostgreSQL (read-only)
Depends onuns-historian, uns-log
Dashboards5 (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

DashboardSourceKey Panels
Machine Overviewuns_historianStatus timeline, spindle RPM, feed rate, uptime, status distribution (time-based)
Productionuns_historianProgram progress gauge, parts vs target, cycle time, deduplicated program history
Toolinguns_historianTool life gauge, offset trend (wear detection), deduplicated tool change history
Status Loguns_logStatus timeline, time-based distribution, full change log with changed fields
KPI Overviewuns_historianUtilisation %, 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:

KPIPanel TypeCalculation
Utilisation %GaugeACTIVE time / total tracked time
Availability %Gauge(total - ALARM - OFFLINE) / total
MTBFStatAvg ACTIVE run duration (minutes)
MTTRStatAvg ALARM duration (minutes)
Stoppage ParetoBar ChartNon-productive states ranked by total time
ThroughputStatParts 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:3001

File 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 →