{
  "name": "Vorlux AI | Performance Monitor",
  "active": false,
  "nodes": [
    { "parameters": { "rule": { "interval": [{ "field": "minutes", "minutesInterval": 15 }] } }, "id": "sched", "name": "Every 15 Min", "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [220, 300] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/health/metrics", "method": "GET", "options": { "timeout": 10000 } }, "id": "fetch-metrics", "name": "Fetch Health Metrics", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 200] },
    { "parameters": { "url": "http://host.docker.internal:3010/api/system/resource-metrics", "method": "GET", "options": { "timeout": 10000 } }, "id": "fetch-resources", "name": "Fetch Resource Metrics", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [460, 400] },
    { "parameters": { "mode": "runOnceForAllItems", "jsCode": "const health = $('Fetch Health Metrics').first().json;\nconst resources = $('Fetch Resource Metrics').first().json;\nconst avgResponseTime = health.avgResponseTime || health.responseTime || 0;\nconst cpuUsage = resources.cpu || resources.cpuUsage || 0;\nconst memUsage = resources.memory || resources.memoryUsage || 0;\nconst alerts = [];\nif (avgResponseTime > 5000) alerts.push('High response time: ' + avgResponseTime + 'ms');\nif (cpuUsage > 80) alerts.push('High CPU: ' + cpuUsage + '%');\nif (memUsage > 85) alerts.push('High Memory: ' + memUsage + '%');\nreturn [{ json: { avgResponseTime, cpuUsage, memUsage, alerts, hasAlerts: alerts.length > 0, checkedAt: new Date().toISOString() } }];" }, "id": "analyze", "name": "Analyze Performance", "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [720, 300] },
    { "parameters": { "method": "POST", "url": "={{$env.DISCORD_OPS_WEBHOOK}}", "sendBody": true, "specifyBody": "json", "jsonBody": "={{ $json.hasAlerts ? JSON.stringify({ content: '⚠️ **Performance Alert**\\n' + $json.alerts.join('\\n') }) : JSON.stringify({ content: '✅ Performance OK — Response: ' + $json.avgResponseTime + 'ms, CPU: ' + $json.cpuUsage + '%, Mem: ' + $json.memUsage + '%' }) }}" }, "id": "notify", "name": "Discord Notify", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [960, 300] }
  ],
  "connections": {
    "Every 15 Min": { "main": [[{ "node": "Fetch Health Metrics", "type": "main", "index": 0 }, { "node": "Fetch Resource Metrics", "type": "main", "index": 0 }]] },
    "Fetch Health Metrics": { "main": [[{ "node": "Analyze Performance", "type": "main", "index": 0 }]] },
    "Fetch Resource Metrics": { "main": [[{ "node": "Analyze Performance", "type": "main", "index": 0 }]] },
    "Analyze Performance": { "main": [[{ "node": "Discord Notify", "type": "main", "index": 0 }]] }
  },
  "settings": { "executionOrder": "v1" }
}
