Extending the System

How to add new functions, KPIs, and data sources.

Adding a New Function

# 1. Scaffold
fnkit go uns-alerts

# 2. Connect to infrastructure (.env)
FUNCTION_TARGET=uns-alerts
CACHE_URL=redis://fnkit-cache:6379
DATABASE_URL=postgres://fnkit:fnkit@fnkit-postgres:5432/fnkit

# 3. Write handler (follow patterns)
# 4. Set Valkey config
docker exec fnkit-cache valkey-cli SET fnkit:config:uns-alerts \
  '{"topics":["v1.0/.../cnc-01/status"],"threshold":300}'

# 5. Deploy
docker compose up -d

Adding a New KPI

Write SQL query, add to uns-kpi/function.go, include in response.

Adding Real Data Sources

OptionDescription
OPC UA gatewayPublish PLC data to UNS topics
Custom edge functionfnkit MQTT function reading machine API
Direct MQTTModern PLCs with native MQTT