{
  "name": "Scheduled System Check",
  "active": false,
  "nodes": [
    {
      "id": "schedule-trigger",
      "name": "Every 5 Minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        100,
        300
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 5
            }
          ]
        }
      }
    },
    {
      "id": "health-check",
      "name": "Health Check",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        340,
        300
      ],
      "parameters": {
        "url": "http://n8n:5678/healthz",
        "method": "GET",
        "authentication": "none",
        "options": {
          "timeout": 5000
        }
      }
    },
    {
      "id": "format-status",
      "name": "Format Status",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        580,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// format health check result into a status report\nconst results = [];\n\nfor (const item of items) {\n  const statusCode = item.json.statusCode || 200;\n  const healthy = statusCode >= 200 && statusCode < 300;\n\n  results.push({\n    json: {\n      service: 'n8n',\n      healthy: healthy,\n      statusCode: statusCode,\n      checkedAt: new Date().toISOString(),\n      message: healthy ? 'n8n is running normally' : `n8n returned status ${statusCode}`\n    }\n  });\n}\n\nreturn results;"
      }
    },
    {
      "id": "check-healthy",
      "name": "Is Healthy?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        820,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict"
          },
          "conditions": [
            {
              "id": "condition-healthy",
              "leftValue": "={{ $json.healthy }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "log-success",
      "name": "Log Success",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1060,
        200
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// log successful health check\nfor (const item of items) {\n  item.json.logLevel = 'info';\n  item.json.action = 'none';\n}\n\nreturn items;"
      }
    },
    {
      "id": "log-failure",
      "name": "Log Failure",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1060,
        400
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// log failed health check\nfor (const item of items) {\n  item.json.logLevel = 'error';\n  item.json.action = 'alert';\n  item.json.alert = `n8n health check failed at ${item.json.checkedAt}`;\n}\n\nreturn items;"
      }
    }
  ],
  "connections": {
    "Every 5 Minutes": {
      "main": [
        [
          {
            "node": "Health Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Health Check": {
      "main": [
        [
          {
            "node": "Format Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Status": {
      "main": [
        [
          {
            "node": "Is Healthy?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Healthy?": {
      "main": [
        [
          {
            "node": "Log Success",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Failure",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}