--- alias: user-guide-business-intelligence-real-time-uns-analytics tags: - dashboards - UNS - CDM - real-time summary: "Leverage real-time CDM events from the Unified Namespace to monitor resource states, material operations, and shop-floor performance" --- # Real-Time Analytics with UNS Events ## Overview When the Unified Namespace (UNS) Export Integration is configured, CDM events are published in real time to an MQTT broker. These events provide immediate visibility into shop-floor operations — resource state changes, material movements, and production activities — without waiting for batch reporting or data warehouse aggregation. This page explains how production managers, quality engineers, and operations teams can use real-time UNS event data to enhance decision-making, monitor performance, and respond to issues as they happen. !!! info Real-time UNS analytics complement the existing Analytics Views available in the Business Intelligence section. While Analytics Views query historical data from the ODS and Data Warehouse, UNS-based dashboards reflect the current state of the shop floor with sub-second latency. ## How Real-Time UNS Data Differs from Historical Reporting | Characteristic | Historical Reporting (Analytics Views) | Real-Time UNS Events | | --- | --- | --- | | **Data source** | ODS / Data Warehouse / ClickHouse CDM | MQTT broker (live event stream) | | **Latency** | Minutes to hours (replication + aggregation) | Milliseconds (event-driven) | | **Use case** | Trend analysis, shift reports, compliance | Instant alerts, live dashboards, immediate response | | **Data format** | Aggregated metrics | Individual CDM events with full context | | **Previous state** | Requires historical query | Embedded in each event payload | Table: Comparison of Reporting Approaches Both approaches are valuable and serve different decision-making contexts. Use historical reporting for trend analysis and KPI tracking; use real-time UNS events for immediate operational awareness. ## What You Can Monitor in Real Time ### Resource State Monitoring When resources (equipment, workstations) change state, `ResourceStateChange` events are published instantly. Each event includes: - **Current state** — the new SEMI-E10 state (for example, Productive, Standby, Unscheduled Down). - **Previous state** — the state before the transition, embedded directly in the event payload. - **Hierarchy context** — which enterprise, site, area, and facility the resource belongs to. **Example use cases:** | Scenario | Benefit | | --- | --- | | A resource transitions to `Unscheduled Down` | Operations teams are notified immediately and can dispatch maintenance. | | Multiple resources in an area go to `Standby` simultaneously | May indicate upstream material shortage — supervisors can investigate. | | Productive time tracking | Real-time OEE calculation without waiting for shift-end reports. | ### Material Operations Tracking `MaterialOperations` events capture material movements, including TrackIn, TrackOut, MoveNext, and other operations. Each event includes the material lot, resource, and operation context. **Example use cases:** | Scenario | Benefit | | --- | --- | | Material tracked in at a resource | Real-time WIP (Work In Progress) visualization. | | Material tracked out with quality outcome | Instant yield monitoring — flagging low-yield operations. | | Material movement across areas | End-to-end genealogy tracking for compliance. | ### Data Collection Events `PostDataCollection` events are published when data collection operations complete, providing immediate access to measurement data. ## Connecting External Dashboards Real-time UNS events can be consumed by any MQTT-compatible visualization tool. Common options include: ### Grafana with MQTT Data Source Grafana can subscribe to MQTT topics and display live panels: 1. Install the MQTT data source plugin in your Grafana instance. 2. Configure the data source with your MQTT broker connection details. 3. Create panels that subscribe to specific topics (for example, `+/+/+/+/ResourceStateChange`). 4. Use Grafana's transformation and filtering capabilities to focus on specific resources or areas. ### Node-RED Dashboards Node-RED provides a low-code environment for building real-time dashboards: 1. Use the `mqtt in` node to subscribe to CDM event topics. 2. Use `json` and `function` nodes to parse and transform payloads. 3. Display results using dashboard nodes (gauges, charts, tables). ### Custom Web Applications Custom applications can use MQTT over WebSockets (typically available on port `8083` or `8084` for TLS) to display live data in a browser: 1. Connect to the MQTT broker using a JavaScript MQTT library (for example, MQTT.js). 2. Subscribe to relevant topics. 3. Update the UI as events arrive. ## Understanding the Event Payload Each CDM event published to the MQTT broker carries a self-contained JSON payload with full manufacturing context. ### Key Sections | Section | What it tells you | | --- | --- | | **Header** | When the event occurred (`DateTime`), which CDM version produced it, and correlation information for tracing. | | **Enterprise / Site / Area** | Where in the manufacturing hierarchy the event originated. Enables filtering by facility or production area. | | **Resource** | Which equipment or workstation is involved, including current SEMI-E10 state, system state, and classification. | | **Previous** | The prior state of the entity before this event. Allows detecting transitions (for example, Standby → Productive) without maintaining external state. | ### Reading State Transitions The `Previous` section is especially valuable for operations monitoring. For a `ResourceStateChange` event: - **Current state**: `Resource.SEMIE10State` = `Productive` - **Previous state**: `Previous.Resource.SEMIE10State` = `Standby` This tells you that the resource transitioned from Standby to Productive, without needing to store or query historical records. ## Combining Real-Time and Historical Data For comprehensive shop-floor monitoring, combine both data streams: | Layer | Source | Purpose | | --- | --- | --- | | **Live alerts and status** | UNS/MQTT events | Immediate awareness of current state | | **Trend analysis** | [[user-guide-analytics-view-index]] (Resource History, State) | Shift and daily pattern analysis | | **KPI dashboards** | [[user-guide-business-intelligence-dashboard-resource-performance]] | Performance metrics over time | | **Compliance reporting** | Analytics Views (Material History, Quality Reports) | Auditable historical records | ## Topic Subscription Patterns To monitor specific aspects of the shop floor, subscribe to targeted MQTT topics: | Monitoring Goal | MQTT Subscription | | --- | --- | | All events from your site | `YourEnterprise/YourSite/#` | | Resource state changes in one area | `+/+/YourArea/+/ResourceStateChange` | | All events for a specific resource | `+/+/+/Baker-01/#` | | All material operations enterprise-wide | `+/+/+/+/MaterialOperations` | | Everything (development/debugging only) | `#` | !!! warning Subscribing to `#` in a production environment can generate significant message volume. Use targeted subscriptions in production. ## Getting Started To start using real-time UNS analytics: 1. **Verify the integration is active** — confirm with your system administrator that the UNS Export Integration is configured and events are flowing. See [[operation-guide-configuring-uns-export-integration]]. 2. **Choose a visualization tool** — select Grafana, Node-RED, a custom application, or any MQTT-compatible dashboard. 3. **Connect to the broker** — obtain the MQTT connection details from your administrator. 4. **Subscribe to relevant topics** — start with broad subscriptions and narrow based on your monitoring needs. ## Related Topics - [[tutorials-realtime-insights]] — tutorial for configuring UNS Export Integration - [Guides: UNS Integration Customization](https://developer.criticalmanufacturing.com/explore/guides/customizations/integration/uns/) — developer guide for customizing UNS integration, namely building MQTT consumers - [[operation-guide-uns-topic-mapping]] — topic structure and customization reference