uns-kpi — KPI Reporter
Computes manufacturing KPIs by querying all PostgreSQL tables. Pure read, no config needed.
| Language | Go |
| Type | HTTP function (read-only) |
| Scaffolded with | fnkit go |
| Depends on | PostgreSQL (all tables) |
What It Does
Queries all PostgreSQL tables and computes manufacturing KPIs on demand. No cache, no config — just SQL and JSON.
KPIs
| KPI | Source | Calculation |
| Utilisation % | uns_state | ACTIVE / total time |
| Availability % | uns_state + uns_stoppage | (total - unplanned) / total |
| Throughput | uns_productivity | parts/hr, target % |
| Stoppage pareto | uns_stoppage | Top reasons by duration |
| MTBF | uns_state | Avg ACTIVE before ALARM |
| MTTR | uns_state | Avg ALARM duration |
| Scrap | uns_input | Total scrap per machine |
API
GET /uns-kpi # all KPIs, 24h
GET /uns-kpi?hours=8&machine=cnc-01 # filtered
GET /uns-kpi?area=area1&hours=24 # by area
Parameters
| Param | Default | Description |
| machine | (all) | Filter by machine |
| area | (all) | Filter by area |
| hours | 24 | Last N hours |
| from/to | - | RFC3339 time range |
Quick Start
cd uns-kpi && cp .env.example .env && docker compose up -d
curl "http://localhost:8080/uns-kpi?hours=8" | jq