N
n8n Store
Workflow Market
Website & API Health Monitoring System with HTTP Status Validation

Website & API Health Monitoring System with HTTP Status Validation

by epolat0 views

Description

Categories

🚀 DevOps

Nodes Used

n8n-nodes-base.ifn8n-nodes-base.ifn8n-nodes-base.setn8n-nodes-base.coden8n-nodes-base.coden8n-nodes-base.coden8n-nodes-base.coden8n-nodes-base.webhookn8n-nodes-base.stickyNoten8n-nodes-base.stickyNote
PriceGratis
Views0
Last Updated11/28/2025
workflow.json
{
  "meta": {
    "instanceId": "6d51f49bab6b0dffc9b87e9dabbeb0e9b71c14bdaab2b96ec32b663d472dacc3"
  },
  "nodes": [
    {
      "id": "621e8816-888e-47a1-8bf4-314e68b92dff",
      "name": "Trigger (Webhook)",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -656,
        544
      ],
      "webhookId": "a92b931c-6fd7-4115-be32-40ee0ac9de1b",
      "parameters": {
        "path": "website-check",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "29d1a8bf-5967-4738-9eee-0cf00d5587d1",
      "name": "Set Defaults",
      "type": "n8n-nodes-base.set",
      "position": [
        -432,
        544
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "0782f86f-5c5c-408a-995e-93f5e67c8ca5",
      "name": "HTTP (Ping)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -208,
        544
      ],
      "parameters": {
        "url": "={{ $json.body.url }}",
        "options": {
          "timeout": "={{ $json.body.timeoutMs }}",
          "response": {}
        }
      },
      "typeVersion": 4
    },
    {
      "id": "1a6612e0-b71b-46b1-9a69-7dbde08244e9",
      "name": "IF Status < expect",
      "type": "n8n-nodes-base.if",
      "position": [
        32,
        544
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "number": [
            {
              "value1": "={{ $json.statusCode }}",
              "value2": "={{ $json.body.expectStatusUnder }}",
              "operation": "smaller"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "7c1e04f6-7281-4fe7-8a7f-942cda1f53f5",
      "name": "Health Check (Auto)",
      "type": "n8n-nodes-base.code",
      "position": [
        272,
        480
      ],
      "parameters": {
        "jsCode": "// Always perform basic health check on JSON response\nconst body = $json.body.body;\nlet healthStatus = 'unknown';\nlet isHealthy = false;\n\n// Check common health check patterns\nif (body && typeof body === 'object') {\n  // Check for common health indicators\n  if (body.status === 'ok' || body.status === 'UP' || body.status === 'healthy') {\n    healthStatus = body.status;\n    isHealthy = true;\n  } else if (body.health === 'ok' || body.health === 'UP' || body.health === 'healthy') {\n    healthStatus = body.health;\n    isHealthy = true;\n  } else if (body.state === 'ok' || body.state === 'UP' || body.state === 'healthy') {\n    healthStatus = body.state;\n    isHealthy = true;\n  } else if (body.ok === true) {\n    healthStatus = 'ok';\n    isHealthy = true;\n  } else {\n    // If no clear health indicator, assume healthy if we got a valid JSON response\n    healthStatus = 'response_received';\n    isHealthy = true;\n  }\n} else {\n  // No JSON body or invalid JSON\n  healthStatus = 'no_json';\n  isHealthy = false;\n}\n\nreturn {\n  healthCheck: 'performed',\n  healthStatus: healthStatus,\n  pass: isHealthy,\n  responseBody: body\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "e1811eac-a0d4-4320-a961-b8114f82620b",
      "name": "IF Health passes",
      "type": "n8n-nodes-base.if",
      "position": [
        496,
        480
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.pass }}",
              "operation": "true"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "dd5c7ed7-c83c-47b9-80ad-c538b6c52a56",
      "name": "Ping → OK",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        432
      ],
      "parameters": {
        "jsCode": "return {\n  ok: true,\n  detail: 'Status and Health OK',\n  statusCode: $json.body.statusCode,\n  healthStatus: $json.body.healthStatus,\n  timestamp: new Date().toISOString()\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "704775dd-5de5-4e86-ba38-2ba4b3b472aa",
      "name": "Ping → FAIL (Health)",
      "type": "n8n-nodes-base.code",
      "position": [
        736,
        656
      ],
      "parameters": {
        "jsCode": "return {\n  ok: false,\n  error: 'Health check failed',\n  statusCode: $json.body.statusCode,\n  healthStatus: $json.body.healthStatus,\n  responseBody: $json.body.responseBody,\n  timestamp: new Date().toISOString()\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "4876e4a1-9b45-4c43-93b1-f4ddb8fd3039",
      "name": "Ping → FAIL (Status)",
      "type": "n8n-nodes-base.code",
      "position": [
        272,
        656
      ],
      "parameters": {
        "jsCode": "return {\n  ok: false,\n  error: 'HTTP status not acceptable',\n  statusCode: $json.body.statusCode,\n  timestamp: new Date().toISOString()\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "d38463bd-cfc6-4fb4-bd88-feb5c59d354f",
      "name": "Respond (JSON)",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        944,
        544
      ],
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "json",
        "responseBody": "={{ $json }}"
      },
      "typeVersion": 1
    },
    {
      "id": "5fda4dc1-7b89-49d6-acb6-9dfec7ff7f70",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -272,
        336
      ],
      "parameters": {
        "width": 272,
        "height": 208,
        "content": "## START HERE\n- Send POST request to webhook with URL parameter\n- Configure timeout and status expectations\n- Example: {\"url\": \"https://your-site.com\"}"
      },
      "typeVersion": 1
    },
    {
      "id": "8a903893-2a7c-4ea4-b9ae-9f84ad812899",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        192,
        240
      ],
      "parameters": {
        "width": 256,
        "height": 224,
        "content": "## HEALTH VALIDATION\n- Analyzes JSON response for health indicators\n- Looks for status, health, or ok fields in response body\n- No valid JSON response triggers health failure"
      },
      "typeVersion": 1
    },
    {
      "id": "658a6a7f-16d6-4a62-ad9d-6c94eae0e07d",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        240
      ],
      "parameters": {
        "width": 256,
        "height": 192,
        "content": "## RESPONSE PATHS\n- OK: Status and health checks pass\n- FAIL (Health): Health check fails despite good status  \n- FAIL (Status): HTTP status code above expected threshold"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "HTTP (Ping)": {
      "main": [
        [
          {
            "node": "IF Status < expect",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ping → OK": {
      "main": [
        [
          {
            "node": "Respond (JSON)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Defaults": {
      "main": [
        [
          {
            "node": "HTTP (Ping)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Health passes": {
      "main": [
        [
          {
            "node": "Ping → OK",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ping → FAIL (Health)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Trigger (Webhook)": {
      "main": [
        [
          {
            "node": "Set Defaults",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF Status < expect": {
      "main": [
        [
          {
            "node": "Health Check (Auto)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Ping → FAIL (Status)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Health Check (Auto)": {
      "main": [
        [
          {
            "node": "IF Health passes",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ping → FAIL (Health)": {
      "main": [
        [
          {
            "node": "Respond (JSON)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ping → FAIL (Status)": {
      "main": [
        [
          {
            "node": "Respond (JSON)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

相关工作流