Monitoring
Health Monitoring
Health Check Endpoints javascript
// Custom health check flow
GET /health/status // Basic health status
GET /health/metrics // Performance metrics
GET /health/dependencies // External dependency status
System Metrics
javascript
// Memory usage monitoring
const memUsage = process.memoryUsage();
msg.payload = {
rss: memUsage.rss,
heapTotal: memUsage.heapTotal,
heapUsed: memUsage.heapUsed,
external: memUsage.external
};
Performance Monitoring
Flow Performance Metrics javascript
// Flow execution time tracking
{
"flowId": "flow-123",
"executionTime": 150,
"nodeCount": 25,
"messageCount": 1000,
"timestamp": "2024-01-15T10:30:00Z"
}
Node Performance Monitoring
javascript
// Node execution statistics
{
"nodeId": "node-456",
"type": "function",
"executionCount": 500,
"averageExecutionTime": 5.2,
"errorCount": 2,
"lastError": "2024-01-15T10:25:00Z"
}
Logging and Alerting
Structured Logging javascript
// Log message format
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "info",
"msg": "Flow deployed successfully",
"flowId": "flow-123",
"nodeCount": 25,
"userId": "admin"
}
Alert Configuration
javascript
// Alert thresholds
{
"memory": {
"warning": 80,
"critical": 90
},
"cpu": {
"warning": 70,
"critical": 85
},
"responseTime": {
"warning": 1000,
"critical": 5000
}
}
Monitoring Tools Integration
Prometheus Integration javascript
// Install Prometheus metrics node
npm install node-red-contrib-prometheus-exporter
// Metrics endpoint
GET /metrics
Grafana Dashboard
json
{
"dashboard": {
"title": "Node-RED Monitoring",
"panels": [
{
"title": "Flow Execution Rate",
"type": "graph",
"targets": [
{
"expr": "rate(node_red_flows_executed_total[5m])"
}
]
}
]
}
}