uns-kpi — KPI Reporter

Computes manufacturing KPIs by querying all PostgreSQL tables. Pure read, no config needed.

LanguageGo
TypeHTTP function (read-only)
Scaffolded withfnkit go
Depends onPostgreSQL (all tables)

What It Does

Queries all PostgreSQL tables and computes manufacturing KPIs on demand. No cache, no config — just SQL and JSON.

KPIs

KPISourceCalculation
Utilisation %uns_stateACTIVE / total time
Availability %uns_state + uns_stoppage(total - unplanned) / total
Throughputuns_productivityparts/hr, target %
Stoppage paretouns_stoppageTop reasons by duration
MTBFuns_stateAvg ACTIVE before ALARM
MTTRuns_stateAvg ALARM duration
Scrapuns_inputTotal 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

ParamDefaultDescription
machine(all)Filter by machine
area(all)Filter by area
hours24Last 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