Monitor Event
The OPC UA Monitor Event node enables real-time monitoring of events emitted by objects on an OPC UA server. Events represent discrete occurrences such as alarms, state changes, user actions, and system notifications.
Overview
Unlike variable monitoring which tracks continuous value changes, event monitoring captures specific occurrences like alarm activations, equipment state transitions, or audit events. Events carry structured information defined by their event type, including severity, message, timestamp, and type-specific fields.
Key Features:
- Event Filtering: Use Where Clauses to select specific event types
- Field Selection: Choose which event fields to receive
- Alarm Monitoring: Track alarm conditions and states
- Audit Logging: Monitor user actions and security events
- System Events: Track server status and diagnostics
Tutorials
- Monitoring OPC UA Events - Complete guide to monitoring events, alarms, and conditions
- Tips & Best Practices - Optimization techniques and best practices
- Troubleshooting - Solutions to common problems
Quick Start
Basic Example - Monitor All Server Events:
- Add a Monitor Event node to your flow
- Configure the OPC UA endpoint
- Select a subscription
- Set NodeId to
i=2253(Server object) - Leave Where Clause empty (all events)
- Set Select Clause to:
EventId,Time,Message,Severity - Deploy your flow
The node will send messages whenever events occur on the server.
Event Concepts
Event Types
OPC UA defines a hierarchy of event types:
- BaseEventType: Root of all events
- SystemEventType: System status events
- AlarmConditionType: Alarms and conditions
- LimitAlarmType: High/low limit alarms
- DiscreteAlarmType: Binary state alarms
- AuditEventType: Security and user actions
Event Fields
Common fields available in most events:
| Field | Description |
|---|---|
| EventId | Unique identifier for this event occurrence |
| EventType | NodeId of the event type definition |
| SourceName | Name of the object that generated the event |
| Time | When the event occurred |
| Message | Human-readable description |
| Severity | Importance level (1-1000) |
Where Clause
Filters which events are received:
// Only alarm events
ofType("AlarmConditionType")
// High severity events
Severity >= 700
// Specific source
SourceName = "Reactor1"
Select Clause
Specifies which fields to retrieve:
EventId,EventType,SourceName,Time,Message,Severity
Use the graphical selector (... button) to browse and select available fields.
Use Cases
Alarm Management
Monitor critical equipment alarms:
// Where Clause
ofType("AlarmConditionType") AND Severity >= 600
// Select Clause
EventId,Time,Message,Severity,ActiveState,AckedState,SourceName
Process alarms:
if (msg.payload.ActiveState && !msg.payload.AckedState) {
// Send notification for active, unacknowledged alarms
node.send(msg);
}
Audit Logging
Track user actions and security events:
// Where Clause
ofType("AuditEventType")
// Log to database
msg.topic = "INSERT INTO audit_log VALUES (?, ?, ?)";
msg.params = [msg.payload.Time, msg.payload.Message, msg.payload.SourceName];
System Monitoring
Monitor server health and status:
// Where Clause
ofType("SystemEventType")
// Alert on critical system events
if (msg.payload.Severity >= 800) {
msg.payload = "Critical system event: " + msg.payload.Message;
node.send(msg);
}
Event Dashboard
Create real-time event displays:
// Format for dashboard
const level = msg.payload.Severity >= 800 ? "critical" :
msg.payload.Severity >= 600 ? "warning" : "info";
msg.payload = {
level: level,
title: msg.payload.SourceName,
message: msg.payload.Message,
timestamp: new Date(msg.payload.Time)
};
Configuration Parameters
Common Settings
| Parameter | Description |
|---|---|
| Name | Node identifier in the flow |
| Endpoint | OPC UA server connection |
| Subscription | Subscription for event monitoring |
| NodeId | Object that emits events (e.g., Server, equipment) |
| Where Clause | Filter expression for event types/properties |
| Select Clause | Comma-separated list of fields to retrieve |
Event Source Objects
Common NodeIds for event monitoring:
- Server object:
i=2253(system-wide events) - Equipment objects:
ns=2;s=Equipment.Reactor1 - Folder objects: Aggregate events from children
Severity Levels
OPC UA standard severity ranges (0-1000):
| Range | Level | Description |
|---|---|---|
| 1-200 | Low | Informational events |
| 201-400 | Low-Medium | Minor issues |
| 401-600 | Medium | Noteworthy conditions |
| 601-800 | Medium-High | Important warnings |
| 801-1000 | High | Critical alarms |
Example filtering:
// Only high-priority events
Severity >= 600
Message Format
Standard output message:
{
"topic": "event",
"payload": {
"EventId": "4f3b2a1c...",
"EventType": "ns=0;i=2041",
"SourceName": "Reactor1",
"Time": "2024-11-24T10:30:45.123Z",
"Message": "Temperature exceeded limit",
"Severity": 800
}
}
For alarm events with additional fields:
{
"payload": {
"EventId": "4f3b2a1c...",
"Time": "2024-11-24T10:30:45.123Z",
"Message": "High temperature alarm",
"Severity": 850,
"SourceName": "Reactor1",
"ActiveState": true,
"AckedState": false,
"ConditionName": "HighTemperatureAlarm"
}
}
Tips & Best Practices
Filter at the Server
Use Where Clauses to filter events at the source rather than in Node-RED:
✅ Efficient:
whereClause: "ofType('AlarmConditionType') AND Severity >= 700"
❌ Inefficient:
whereClause: "" // Receive all events
// Filter in function node
Select Minimal Fields
Request only the fields you need to reduce message size and processing:
✅ Good:
EventId,Time,Message,Severity
❌ Excessive:
EventId,EventType,SourceNode,SourceName,Time,ReceiveTime,LocalTime,Message,Severity,...
Use the Graphical Selector
The easiest way to build Select Clauses:
- Click
...button next to Select Clause - Browse the event type hierarchy
- Check desired fields
- Clause is auto-generated
Handle High-Frequency Events
Implement rate limiting or aggregation:
// Function node: Aggregate events
const events = context.get('events') || [];
events.push(msg.payload);
// Emit summary every 5 seconds
const lastEmit = context.get('lastEmit') || 0;
const now = Date.now();
if (now - lastEmit > 5000) {
msg.payload = {
count: events.length,
events: events
};
context.set('events', []);
context.set('lastEmit', now);
return msg;
}
return null;
Troubleshooting
No Events Received
- Verify server supports event monitoring
- Check NodeId points to event-generating object
- Try Server object (
i=2253) - Remove Where Clause to see all events
- Verify subscription is active
Too Many Events
- Add Where Clause to filter by type
- Filter by severity:
Severity >= 600 - Monitor specific equipment instead of Server
- Implement rate limiting in Node-RED
Missing Event Fields
- Use graphical selector to see available fields
- Check event type documentation
- Some fields only exist for certain event types
- Start with basic fields
Event Delays
- Reduce subscription publishing interval
- Check network latency
- Verify server performance
- Review queue sizes
Related Sections
- Monitor Variables - Monitor value changes
- Connection - Configure subscriptions
- Explore - Discover event-generating objects